Can’t Use Method Return Value in Write Context – PHP Error

I got following fatal error in php can’t use method return value in write context. When this fatal error comes i didn’t understand what’s wrong with my code, as everything looks fine in my code editor. So i started debugging what’s the root cause for this error.

PHP solution for Can’t use method return value in write context

I was using Yii framework. In my Yii application i have written following statement.

To solve current fatal error i break single statement into two. Now the issue is resolved.

PHP manual clearly mentioned following things.

Subscribe Our Tutorials

Get Latest Updates on Facebook

Prior to PHP 5.5, empty() only supports variables; anything else will result in a parse error. In other words, the following will not work: empty(trim($name)). Instead, use trim($name) == false.

To prevent this error other option is to upgrade your php version. My php version was PHP 5.4 . Now i upgraded to PHP version 5.6. After upgrading my php version this issue is automatically resolved.

How to install LAMP on ubuntu.

I am using Mac so here is terminal command to unlink php 5.4 and install php 5.6 version.

To check current php version.

About WebRewrite

I am technology lover who loves to keep updated with latest technology. My interest field is Web Development.
Tagged , , . Bookmark the permalink.