小白求指点:自定义函数内调用另外一个函数里的全局变量,该如何写

WBOY
Release: 2016-06-13 12:20:12
Original
998 people have browsed it

小白求指点:自定义函数内调用另外一个函数里的全局变量,该怎么写啊
member.inc.php:

function marrbase(){<br />if(isset($_COOKIE["uname"]) && isset($_COOKIE["uid"])){<br />global $mbase;<br />$mbase_data = mysql_query("select * from dh_member where `id`=" . $_COOKIE["uid"] . " and `mck`=1");<br />if (!$mbase_data){die(mysql_error());exit();}<br />$mbase = mysql_fetch_array($mbase_data);<br />}<br />else{exit();}<br />}
Copy after login


我是这样写的:
<br />require_once("member.inc.php");<br />function supp(){<br />marrbase();<br />echo $mbase["email"]; exit();<br />}<br />
Copy after login


输出为空,小白求大神指点一下这个该怎么写才规范正确啊..


------解决思路----------------------
function supp() {
  global $mbase;
  marrbase();
  echo $mbase["email"]; exit();
}

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!