开发者

Is it possible to have a variable accessible and modified by different functions of the same class in PHP?

开发者 https://www.devze.com 2023-01-30 17:59 出处:网络
I declare a variable as private in the body of the class and set it to null. After that, I access the variable by a function in the class and initialize it. When I try to rea开发者_JAVA技巧d the value

I declare a variable as private in the body of the class and set it to null. After that, I access the variable by a function in the class and initialize it. When I try to rea开发者_JAVA技巧d the value of this variable from another function, it's always null! Did I miss something?


ooooo I did a big mistake. I was accessing the variables like that

$variable

instead of

$this->variable
0

精彩评论

暂无评论...
验证码 换一张
取 消