[英]Array to string conversion in php _construct()
我有一個帶有__construct()方法的PHP類。 我傳遞參數並將其存儲在屬性中。 像這樣:
class BlogList {
private $app_config, $texts;
public function __construct($app_config, $texts) {
$this->$app_config = $app_config;
$this->$texts = $texts;
}
...
}
當我創建此類的實例時,我看到日志顯示了這樣的內容:
PHP Notice: Array to string conversion in /path/to/blogList.php on line 6
我在__construct方法中的兩個分配中都得到了這個。 $ app_config和$ texts都是數組
為什么要完成轉換? 我該如何預防呢?
分配應為:
public function __construct($app_config, $texts) {
$this->app_config = $app_config;
$this->texts = $texts;
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.