php - if not working with decrement/increment -


hi i´m new in php , in 1 book found this:

$x = 0;     if ($x-- == 0) echo $x; 

in book write should write -1 page, because decremenet done after comparison , before command exho executed. understand why that, when type editor it's giving me error because it's understanding $x-- 1 , $x variable. where's problem?

basic steps :

step 1: (get notepad++)

go http://notepad-plus-plus.org/ , download notepad++.
notepad++ free (as in "free speech" , in "free beer") source code editor , notepad replacement supports several languages. running in ms windows environment, use governed gpl license.

step 2: (type code)

type , save "filename.php" in "www directory"

<?php  $x = 0;     if ($x-- == 0) echo $x;  ?> 

step 3: (enjoy !)

check result

expected output : -1 // got! :d


Comments