I have created a session variable to store some basic stats:

 $_SESSION['stats'] = array('likecount' => 0, 'failedlikes' => 0);

Further down I have a line which increments it:

$_SESSION['stats']->likecount++;

However, this throws the error Attempt to increment/decrement property of non-object. What am I doing wrong?

有帮助吗?

解决方案

You're dealing with an array, not with an object, so you should use

$_SESSION['stats']['likecount']++; 
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top