ss.php
<?php
class Song{
public function __construct(){
echo "construct";
}
public function Song(){
echo "ssss";
}
}
?>
c2.php
<?php
include ("./ss.php");
class CC{
$song=new Song();
}
?>c2 编译不过 为什么呢?
<?php
class Song{
public function __construct(){
echo "construct";
}
public function Song(){
echo "ssss";
}
}
?>
c2.php
<?php
include ("./ss.php");
class CC{
$song=new Song();
}
?>c2 编译不过 为什么呢?
属性中的变量可以初始化,但是初始化的值必须是常数,这里的常数是指php脚本在编译阶段时就为常数,而不是在编译阶段之后在运行阶段运算出的常数。 显然new Song()不是常数。
include ("./ss.php");
class CC{
public $song;
public function __construct(){
$this->song=new Song();
}
}