From: Operating system: CentOS release 5.4 (Final) PHP version: 5.3.8 Package: Scripting Engine problem Bug Type: Bug Bug description:print() results in bad logic
Description: ------------ Unlike echo, the print construct is allowed inside logic clauses. If it is reached (not short-circuited), it will cause the rest of that clause to be true. Tested with 5.3.8 and PHP 5.3.9RC5-dev, both with default configure. Test script: --------------- <?php echo (false && print('')) ? "Fail\n" : "Pass\n"; echo (print('') && false) ? "Fail\n" : "Pass\n"; echo (print('') && false && false) ? "Fail\n" : "Pass\n"; echo ((print('') && false) && true) ? "Fail\n" : "Pass\n"; echo ((print('') && false) && false) ? "Fail\n" : "Pass\n"; ?> Expected result: ---------------- The word "Pass" five times. Actual result: -------------- The middle three fail. The first and last pass, and are included to demonstrate the limits of the bug. -- Edit bug report at https://bugs.php.net/bug.php?id=60694&edit=1 -- Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=60694&r=trysnapshot54 Try a snapshot (PHP 5.3): https://bugs.php.net/fix.php?id=60694&r=trysnapshot53 Try a snapshot (trunk): https://bugs.php.net/fix.php?id=60694&r=trysnapshottrunk Fixed in SVN: https://bugs.php.net/fix.php?id=60694&r=fixed Fixed in SVN and need be documented: https://bugs.php.net/fix.php?id=60694&r=needdocs Fixed in release: https://bugs.php.net/fix.php?id=60694&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=60694&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=60694&r=needscript Try newer version: https://bugs.php.net/fix.php?id=60694&r=oldversion Not developer issue: https://bugs.php.net/fix.php?id=60694&r=support Expected behavior: https://bugs.php.net/fix.php?id=60694&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=60694&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=60694&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=60694&r=globals PHP 4 support discontinued: https://bugs.php.net/fix.php?id=60694&r=php4 Daylight Savings: https://bugs.php.net/fix.php?id=60694&r=dst IIS Stability: https://bugs.php.net/fix.php?id=60694&r=isapi Install GNU Sed: https://bugs.php.net/fix.php?id=60694&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=60694&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=60694&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=60694&r=mysqlcfg