具有:
class foo {
private $myproperty;
public
function __construct() {
if (
( !isset( $_SESSION ) ) &&
( session_status() == PHP_SESSION_NONE )
) {
session_start();
}
public
function __set( $name, $value ) {
if ( property_exists( "foo", $name ) ) {
$_SESSION[ $name ] = $value;
}
}
public
function __get( $name ) {
if ( property_exists( "foo", $name ) ) {
return $_SESSION[ $name ];
}
}
}
正在做:
$foo = new $foo();
$foo->myproperty = "value";
if ( isset ($foo->myproperty ) ) {
echo "myproperty setted";
} else {
echo "myproperty not setted"
}
为什么要返回"myproperty not setted"?如果我替换为同样的isset问题 empty。是一个错误吗?如果没有,我该如何修复它?
温温酱
慕尼黑的夜晚无繁华