difference between $a==5 and 5==$a in php -


today have faced question, unable answer it, have tried making php program unable find out exact reason if $a=5 both($a==5 , 5==$a) giving me output boolean true and, if $a != 5 both ($a==5 , 5==$a ) giving me output boolean false can tell me difference between $a==5 , 5==$a language point of view.

**program** $a = 3; var_dump( 5==$a ); var_dump( $a==5 ); $a = 5; var_dump( 5==$a ); var_dump( $a==5 );   **output** boolean false  boolean false  boolean true  boolean true 

comparisons not affected value write first. however, best practice put literal first, e.g. 5 == $x because if mess , enter 1 equals sign, you'll error instead of accidental value assignment, far easier debug.


Comments

Popular posts from this blog

Ansible - ERROR! the field 'hosts' is required but was not set -

customize file_field button ruby on rails -

SoapUI on windows 10 - high DPI/4K scaling issue -