|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2013-01-22 00:28 UTC] aharvey@php.net
[2013-01-22 00:28 UTC] aharvey@php.net
-Status: Open
+Status: Not a bug
-Package: *Compile Issues
+Package: Scripting Engine problem
|
|||||||||||||||||||||||||||
Copyright © 2001-2026 The PHP GroupAll rights reserved. |
Last updated: Wed Feb 11 17:00:01 2026 UTC |
Description: ------------ PHP Version 5.3.9-ZS5.6.0 Is it an Complie Error or is it wanted in that way how it works! Please see the "Test Script" & "Actual Result". Only way to go around it (Force negative class_exists check and braces ): if(!class_exists('test')){ class test {} } For me it seems to be that the Compiler complies the hole file and declare directly the given class in the file. Only doesnt declare if the class defenition is within a function. But why can i change the result via 'test' | $t='test' ?? And see "Actual Result" as second question. Test script: --------------- //fileA.php - test is not included yet!! if(class_exists('test')) die('complier has included test'); class test {} //wont work - doesnt include the test class //fileB.php - test is not included yet!! if(class_exists($t='test')) die('wont never happen'); class test {} //works - includes test class Note: if u try that code with eval() both cases wont work! eval("\$t='test'; if(class_exists(\$t)){ die('complier has included test'); } class test {}"); Expected result: ---------------- In thing it is no really cool to always force "class definitions" in an negative "class_exists" check and then drop the class code within the {}. And i cannot really behind the diff. behavior on the eval() tryout. Please Note the add in "Actual Result". Actual result: -------------- //see "Test Script" and here is an crazy tryout on this issue: error_reporting(E_ALL); $t='test'; if(class_exists($t,false)){ echo ('complier has included '.$t);} class test {public $var='1';} class test {public $var='2';} What did you expect? Compile Error before running any Script??? So this: Fatal error: Cannot redeclare class test in C:\xampp\htdocs\js\in.php on line 5 Or this: complier has included test Fatal error: Cannot redeclare class test in C:\xampp\htdocs\js\in.php on line 5 Test it! I thing this behavior is a little bit wired. Maybe only for me ;) Thanks for the time.