Jump to content

PHP fails to parse with $array['foo'] as the value within is_null()


jefftanner

Recommended Posts

I dumbfounded as to why the following code - is_null( $array['foo'] ) fails to parse:

 

[pre]

    if ( is_null( $parsed['text_product_ids'] ) {

          $parsed['text_product_ids'] = '5, 6, 7, 8, 9, 10';

    }

[/pre]

 

But this succeeds to be parsed and executes:

[pre]

    $showSelectedProducts = $parsed['text_product_ids'];

    if ( is_null( $showSelectedProducts ) ) {

          $parsed['text_product_ids'] = '5, 6, 7, 8, 9, 10';

    }

[/pre]

 

Just curious

 

-- Jeff in Seattle

 

     if ( is_null( $parsed['text_product_ids'] ) {
          $parsed['text_product_ids'] = '5, 6, 7, 8, 9, 10';
     }

You have missed a )

should be:

     if (is_null($parsed['text_product_ids'])) {
          $parsed['text_product_ids'] = '5, 6, 7, 8, 9, 10';
     }

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.