Lukas -.-
Lukas -.-

Reputation: 367

any difference between if ('1') and if ('true')?

I read a string from a config file:

boolean = true

Although in php $config["boolean"] => String(1) "1"

is there any difference?

Upvotes: 0

Views: 583

Answers (1)

xayer
xayer

Reputation: 479

Yes difference exists...

In this case

if ('1') and if ('true')

'1' first be converted to true, then executed... But result has been always same...

Of course, exist small speed difference(then need concerted types it's take a little bit more time to do that)... But it's like always - nobody cares :-D

Good to know:

if ( 1 == true) { } // returns true
if ( 1 === true) { } // returns false

enter image description here

enter image description here

Upvotes: 3

Related Questions