Jump to content

if ($_SESSION['uid'] > 0) VS if ($_SESSION['uid'] == 0)


Artsybetty

Recommended Posts

They would be equivalent if done like this:

 


if( !( $var > 0 ) ){}

if( $var == 0 ){} 

However this would be better:

 

if( (int) $var === 0 ){}

 Basically with the latter you're testing type and value. However, remember that if you cast a string as a int which starts with a letter it'll always return 0.

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.