![](/img/trans.png)
[英]What is the correct way to write an SQL statement to push data rows for this array?
[英]What is the correct way to push into an array that is a property of an object?
推入作為對象屬性的數組的正確方法是什么?
錯誤:
Fatal error: Cannot use [] for reading in ... on line ..
碼:
class StreamResponse
{
public $messages ;
function __construct($post)
{
$strippost = stripslashes_deep( $_POST );
foreach ($strippost['messages'] as $message)
{
$m = json_decode($message, true);
$this->$messages[] = $m; //<-- This line is the line with the issue
}
}
}
當你使用$this
時,不要在messages
之前使用美元符號
$this->messages[] = $m;
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.