This is a discussion on I want the explanation for the below example code.. within the PHP Programming forums, part of the Web Development category; "consider the following example $x = true and false; print_r($x); //outputs bool(true) why does the ""and&...
| |||||||
| Register | FAQ | Members List | Calendar | Mark Forums Read |
| |||
| $y = ($x = true and false); var_dump($x); //outputs bool(true) var_dump($y); //outputs bool(false) This is a case of mistaken operator precedence. In this example, the assignment operator (=) has higher precedence than the 'and' operator, so $x is assigned the value true. The second example clears things up a bit. After the first assignment to $x, the return value (true) is anded with false, yielding false, which is assigned to $y. |
![]() |
| Thread Tools | |
| Display Modes | |
| |
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Register dll or ocx using through code in C# | oxygen | C# Programming | 4 | 08-06-2008 12:58 AM |
| C- Tricky Question & answers With explanation | vijayanand | C and C++ Programming | 46 | 01-03-2008 11:00 PM |
| optimizing the code | vijayanand | PHP Programming | 0 | 07-17-2007 12:25 AM |
| JAVA code from PHP | ramkumaraol | PHP Programming | 2 | 07-16-2007 11:54 PM |
| COM - The Short Explanation | Karpagarajan | C and C++ Programming | 0 | 04-10-2007 09:52 AM |