|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2013-10-02 12:20 UTC] nikic@php.net
-Status: Open
+Status: Feedback
[2013-10-02 12:20 UTC] nikic@php.net
[2013-10-02 12:30 UTC] mike@php.net
[2013-10-02 12:49 UTC] florian dot mueller at hostpoint dot ch
[2013-10-15 11:54 UTC] php-bugs at lists dot php dot net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Wed Oct 29 13:00:01 2025 UTC |
Description: ------------ Important: The problem occurs only with php-cgi binary and not with php binary. The problem is, that the following snipped returns NULL instead of true. My guess is, that it has to do with a) if($variable) and b) the fact that "throw new Exception" is the last expression before return. function testMinimal(){ $foo = true; if($foo){ echo ''; } else { throw new Exception('foo'); } return true; } A attached a test script with several cases. For example this one returns NULL as well: function testMinimalDie(){ $foo = true; if($foo){ echo ''; } else { die(); } return true; } whereas those two work: function testMinimalNoVar(){ if(true){ echo ''; } else { throw new Exception('foo'); } return true; } function testMinimalHack(){ $foo = true; if($foo){ echo ''; } else { throw new Exception('foo'); } $someUnrelatedVariable=1; return true; } Test script: --------------- <?php echo "testMinimal "; var_dump(testMinimal()); echo "testMinimalOk "; var_dump(testMinimalOk()); echo "testMinimalNoEx "; var_dump(testMinimalNoEx()); echo "testMinimalDie "; var_dump(testMinimalDie()); echo "testMinimalDivZero "; var_dump(testMinimalDivZero()); echo "testMinimalNoVar "; var_dump(testMinimalNoVar()); echo "testMinimalEEE "; var_dump(testMinimalEEE()); echo "testMinimalEE "; var_dump(testMinimalEE()); echo "testMinimalReturnFalse "; var_dump(testMinimalReturnFalse()); echo "testMinimalHack "; var_dump(testMinimalHack()); function testMinimal(){ $foo = true; if($foo){ echo ''; } else { throw new Exception('foo'); } return true; } function testMinimalHack(){ $foo = true; if($foo){ echo ''; } else { throw new Exception('foo'); } $someUnrelatedVariable=1; return true; } function testMinimalEEE(){ $foo = true; if($foo===true){ echo ''; } else { throw new Exception('foo'); } return true; } function testMinimalEE(){ $foo = true; if($foo==true){ echo ''; } else { throw new Exception('foo'); } return true; } function testMinimalNoVar(){ if(true){ echo ''; } else { throw new Exception('foo'); } return true; } function testMinimalReturnFalse(){ if(true){ echo ''; } else { return false; } return true; } function testMinimalNoEx(){ $foo = true; if($foo){ echo ''; } else { echo 'gugus'; } return true; } function testMinimalDie(){ $foo = true; if($foo){ echo ''; } else { die(); } return true; } function testMinimalDivZero(){ $foo = true; if($foo){ echo ''; } else { 0/0; } return true; } function testMinimalOk(){ $foo = true; if($foo){ echo ''; } return true; } ?> Expected result: ---------------- testMinimal bool(true) testMinimalOk bool(true) testMinimalNoEx bool(true) testMinimalDie bool(true) testMinimalDivZero bool(true) testMinimalNoVar bool(true) testMinimalEEE bool(true) testMinimalEE bool(true) testMinimalReturnFalse bool(true) testMinimalHack bool(true) Actual result: -------------- testMinimal NULL testMinimalOk bool(true) testMinimalNoEx bool(true) testMinimalDie NULL testMinimalDivZero bool(true) testMinimalNoVar bool(true) testMinimalEEE NULL testMinimalEE NULL testMinimalReturnFalse bool(true) testMinimalHack bool(true)