如何在文件外部访问变量? [英] How can I Access Variable outside a file?

查看:110
本文介绍了如何在文件外部访问变量?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


我是php的新手.我需要您的帮助

我必须归档:A,B
在A:

Hi
I am very new to php..I need your help

I have to files: A,B
in A:

class A
public $var;
//
function...{
static $var=0; (as I want to change and keep the value)
if.... $var+=1;

}

?>
在其他文件中,我具有B类

?>
in other file I have Class B

Class B
//
function...{
include(A.class.php)
$var2=new A
if $var2->var1==0  .....



但是问题是它总是返回null ...我想要类A中的最后一个值...但是那不起作用....请对此提供帮助
我想不通!!!


问候



But the problem is it always return null...I want the last value in class A...But that doesnt work....Please help me on this
I cant figure it out!!!


Regards

推荐答案

var; // 功能...{ 静态
var; // function...{ static


var = 0; (因为我想更改并保留值) 如果......
var=0; (as I want to change and keep the value) if....


var + = 1; }
var+=1; }

?>
在其他文件中,我具有B类

?>
in other file I have Class B

Class B
//
function...{
include(A.class.php)


这篇关于如何在文件外部访问变量?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆