更新时间:2021-09-15 05:16:31
如果需要,我总是传入变量名
I always pass in the name of the variable it will be assigned to if it it is required
class myclass {
var $myname;
function __construct($myname='no name') {
$this->myname=$myname;
#print "In BaseClass constructor\n";
}
function sayHello()
{
return "hello from " . $this->myname . "\n";
}
}
用法:
$myVar = new myclass("myVar");
$yourVar = new myclass("yourVar");
echo $myVar->sayHello();
echo $yourVar->sayHello();