<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml-strict.dtd">
<html xmlns = "http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>function _isset()</title>
<link rel = "stylesheet" type = "text/css" href = "common.css"/>
</head>
<body>
<h1>function _isset()</h1>
<?php
class Myclass{
function __isset($propertiesName ){
$string =((substr($propertiesName,0,4) == "test" ) ? "true":"false");
return ($string);
}
}
$testObject = new Myclass;
echo isset($testObject ->banana)."<br/>";
echo isset($testObject ->testbanana)."<br/>";
?>
</body>
</html>

解决方案 »

  1.   

    本来应该返回“true”或是“false”,可结果都是1.
      

  2.   

    "true":"false"换成单引号试试,或者
    $string =((substr($propertiesName,0,4) == "test" ) ? "true":"false");改成substr($propertiesName,0,4) == "test"  ? $string = 'true' : $string = 'false';
      

  3.   

    我知道答案了,其实__isset()函数只能返回true和false,不能返回其他的,__unset()则规定不能返回