【发布时间】:2011-06-24 17:26:12
【问题描述】:
我可以从类外部更改类中定义的函数或变量,但不使用全局变量吗?
这是类,包含文件#2:
class moo{
function whatever(){
$somestuff = "....";
return $somestuff; // <- is it possible to change this from "include file #1"
}
}
在主应用程序中,类是这样使用的:
include "file1.php";
include "file2.php"; // <- this is where the class above is defined
$what = $moo::whatever()
...
【问题讨论】:
-
“包含文件#1”是什么意思?
-
$somestuff似乎是一个局部变量。你不能在$what = moo::whatever()之后改变$what的值吗? -
“更改功能”是什么意思?
-
你的意思是写一个“元”编程来改变一个功能吗?
标签: php class function variables