Some functions require some global variables after the include in PHP, such as global $ db below. how can we solve findall (& #39; members & #39 ;, & quot; WHERE 'uid' & #39; & quot ;. $ uid. & quot; & #39; & quot;); while ($ row $ db-& gt; fetch_array ($ rel) {foreach ($ rowas $ key & gt; $ value) {$ uinfo [$ key] $ v php
After include in PHP, some functions require some global variables, such as global $ db below. how can we solve this problem perfectly without using global?
/*
- Function: detects user logon.
- Parameters:
- Return: boolen/Function check_login () {if (isset ($ _ SESSION ['shell']) = false) return false ;*Global $ db; ** $ uid = $ _ SESSION ['uid']; $ rel = $ db-> findall ('members ', "WHERE
Uid
= '". $ Uid. "'"); while ($ row = $ db-> fetch_array ($ rel) {foreach ($ row as $ key => $ value) {$ uinfo [$ key] = $ value ;}$ ushell = md5 ($ uinfo ['password']. $ uinfo ['role']. DSLOG_ENC); if ($ ushell ==$ _ SESSION ['shell']) {return true;} else {return false ;}}?>