Home  >  Article  >  Database  >  Cannot access empty property

Cannot access empty property

WBOY
WBOYOriginal
2016-06-07 15:43:061379browse

致命错误:不能够进入此空值,位于E:\sunlion\web\down\class\db_sql.php 代码 ?php Class TestClass1{ var $class2; public function TestClass1(){ $this- $class2 = new TestClass2(); } } Class TestClass2{ var $aaaa="1111111"; } $ccc = new TestClas

致命错误:不能够进入此空值,位于E:\sunlion\web\down\class\db_sql.php

代码 
Class TestClass1{ 
var $class2; 
public function TestClass1(){ 
$this-> $class2 = new TestClass2(); 


Class TestClass2{ 
var $aaaa="1111111"; 

$ccc = new TestClass1(); 
echo $ccc-> $class2-> $aaaa; 
?>

错误的地方: 
$this-> $class2 = new TestClass2(); 
改为$this-> class2 = new TestClass2(); 
$this-> 后的变量不带$符

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn