<?php
$ooo=new main();
class CTest
{
public $a="aa";
}
class main
{
private $objTest;
function __construct() {
$objTest=new CTest();
}
function __destruct ( )
{
echo $objTest->a; //为什么出错?
}
function test()
{
echo "a";
}
}
?>
3 个解决方案
#1
class main
{
private $objTest;
function __construct() {
$this->objTest=new CTest();
}
function __destruct ( )
{
echo $this->objTest->a; //为什么出错?
}
function test()
{
echo "a";
}
}
{
private $objTest;
function __construct() {
$this->objTest=new CTest();
}
function __destruct ( )
{
echo $this->objTest->a; //为什么出错?
}
function test()
{
echo "a";
}
}
#2
建议到phpe.net上下几个.class来看,虽然老了的点,不过都很不错哦。
#3
对了刚才看到phpmore上也有相关的资料。可以看看。
http://www.phpe.net/phpmore/VOL5.pdf
http://www.phpe.net/phpmore/VOL5.pdf
#1
class main
{
private $objTest;
function __construct() {
$this->objTest=new CTest();
}
function __destruct ( )
{
echo $this->objTest->a; //为什么出错?
}
function test()
{
echo "a";
}
}
{
private $objTest;
function __construct() {
$this->objTest=new CTest();
}
function __destruct ( )
{
echo $this->objTest->a; //为什么出错?
}
function test()
{
echo "a";
}
}
#2
建议到phpe.net上下几个.class来看,虽然老了的点,不过都很不错哦。
#3
对了刚才看到phpmore上也有相关的资料。可以看看。
http://www.phpe.net/phpmore/VOL5.pdf
http://www.phpe.net/phpmore/VOL5.pdf