PHP头条
热点:

php类文件怎么访问别的文件中的变量


php类文件如何访问别的文件中的变量
我声明了2个文件,一个类文件(123.class.php),一个普通文件(index.php,代码如下),123.class.php中如何获取index.php文件中的$abc的值(在类文件 中直接include不中,获取不到)

123.class.php代码如下:
PHP code





index.php代码:
PHP code





实例化代码:

$abc=new a123;
$abc->index();

------解决方案--------------------
include('index.php');
class a123{
public function index{
global $aa, $bb; //或 include('index.php');
echo $aa;
echo $bb;
}
}
------解决方案--------------------
global

www.phpzy.comtrue/phprm/51987.htmlTechArticlephp类文件怎么访问别的文件中的变量 php类文件如何访问别的文件中的变量 我声明了2个文件,一个类文件(123.class.php),一个普通文件(index.php,代码如下),123.class.php中如何获取i...

相关文章

PHP之友评论

今天推荐