__toString
__toString<style type="text/css">
<!--
body,td,th {
font-size: 12px;
}body {
margin-left:10px;
margin-top: 10px;
margin-right:10px;
margin-bottom: 10px;
}
-->
</style>
<?php
class Myobject{
private $type = 'DIY';
public function __toString(){
return $this -> type;
}
}
$myComputer = new Myobject();
echo '对象$myComputer的值为:';
echo $myComputer;
?>
执行结果:
对象$myComputer的值为:DIY
页:
[1]