fetch_array($rel)) { foreach ($row as $key => $value) { $uinfo[$key] = $v"/> fetch_array($rel)) { foreach ($row as $key => $value) { $uinfo[$key] = $v">

Home  >  Article  >  Backend Development  >  php-PHP中include后,函数中需要global部分变量

php-PHP中include后,函数中需要global部分变量

WBOY
WBOYOriginal
2016-06-02 11:32:471089browse

php

PHP中include后,部分函数中需要global部分变量,例如下面global $db;问,如果不用global,怎么完美解决

/*

  • 功能:检测用户登录
  • 参数:
  • 返回: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;}}?>
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn