Jump to content

if help


davelearning

Recommended Posts

Thanks for the replies

Are they the same including spelling, capitalization, and white space? 'Hello World' does not equal 'Hello world', or 'Hello World ' . . .

 

Yup exactly the same :(

if it's an integer i am pretty sure you don't need those " " around it either.

if ($x == 1) {
  echo 'x is 1';
}

 

I wasnt sure, it works with them in!

 

Link to comment
https://forums.phpfreaks.com/topic/227099-if-help/#findComment-1171587
Share on other sites

They can't be the same. What does var_dump($variable); return?

 

As far as quoting numbers, a number can also be a string. When using the == comparison, PHP's type-juggling will show 10 and "10" to be the same. If you compare them with the identical comparison === operator, it will not.

 

$str = '10'
if( $str == 10 ) { // returns TRUE
if( $str === 10 ) { returns FALSE

Link to comment
https://forums.phpfreaks.com/topic/227099-if-help/#findComment-1171589
Share on other sites

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.