-1
我知道我可以將類A中的方法調用到類B中。但是我想知道是否使用名稱空間來調用另一個類中的函數。如果在PHP中使用「名稱空間和用法」調用另一個類中的函數
namespace tiger
use cat;
class liger{
public $abc;
public function roar(){
return $this->abc->purr();
}
}
// calling the class n the function
$zyx = new liger();
$zyx->roar(); // output blank page....
class cat{
public function purr();
echo "I want to purrrr..!!!!!";
}
ini_set('display_startup_errors',1);
ini_set('display_errors',1);
error_reporting(-1);
OKAY我嘗試錯誤報告,但其仍然是一個空白頁。
你試過了嗎? – APerson 2014-09-30 13:03:00
啓用錯誤報告。這與命名空間無關,但與屬性不是一個對象。 – PeeHaa 2014-09-30 13:03:07