Weird PHP Error: 'Can't Use Function Return Value in Write Context'

Weird PHP error: 'Can't use function return value in write context'

You mean

if (isset($_POST['sms_code']) == TRUE ) {

though incidentally you really mean

if (isset($_POST['sms_code'])) {

Fatal error: Can't use function return value in write context error

You need to change the following line:

if ( ! empty( get_bk_option( 'booking_time_format') ) ) {

To something like this:

$bkOption = get_bk_option( 'booking_time_format');

if ( ! empty( $bkOption ) ) {

Note:

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.

So, your current php version can't handle this. Read the manual for more information.

Getting Can't use function return value in write context

If you refer to a manual, you will see

Determine whether a variable is considered to be empty.

The result of trim passed to empty is not a variable.

So your options are:

$user = trim($_POST['user']);
if (!empty($user)) { }

Or php5.5, in which

empty() now supports expressions

can't use function return value in write context - error in line 7

empty() is a PHP language construct and only supports variables and expressions, and no function calls as arguments.

You will have to assign the result of your call to a variable first and then do the empty check like so:

$reviewPrice = get_post_meta($review->ID,'review_price',true);
if(!empty($reviewPrice)){

Can't use function return value in write context?

From the PHP docs on the empty function:

Note:
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.

So you will have to split that line into something like the following:

$trimDir = trim($Directory);
if(!empty($trimDir))

PHP Fatal Error can't use function return value in write context

you can use this way

$result = $this->getPostArray();//parent::getPostArray()
if (!empty($result)){}


Related Topics



Leave a reply



Submit