关于php类中定义常量问题???<?php
class aa{
public function xx(){
echo "test1";
}
}
class bb extends aa{
const tt="aaaaaaaaa";
public function xx(){
echo "child test";
echo $this->tt;
}
public function called(){
echo "被调用了";
}
}
$obj=new bb();
$obj->xx();
?>
为什么这段代码出错了?错在哪里??为什么错?怎么改?请教高手
代ç è¯ä¿®æ¹å¦ä¸ï¼
public function xx(){echo "child test";
echo self::tt;
}追é®
为ä»ä¹ä¸è½ç¨ $thisæ¥è®¿é®
追çthis ç¨æ¥æåç±»å®ä¾å对象ã
self ç¨æ¥æåç±»æ¬èº«ï¼ä¸è¬ä½¿ç¨ self æ¥æåç±»ä¸çéæåéã
æ以ï¼å½å¨ç±»çå
é¨è®¿é®ç±»ä¸æ个æåæ¶ï¼ä½¿ç¨ self ã
温馨提示:答案为网友推荐,仅供参考