Edit report at https://bugs.php.net/bug.php?id=64036&edit=1

 ID:                 64036
 Updated by:         ahar...@php.net
 Reported by:        dirk dot gerigk at atraveo dot de
 Summary:            class_exists behavior while compile
-Status:             Open
+Status:             Not a bug
 Type:               Bug
-Package:            *Compile Issues
+Package:            Scripting Engine problem
 Operating System:   Linux
 PHP Version:        Irrelevant
 Block user comment: N
 Private report:     N

 New Comment:

Sorry, but your problem does not imply a bug in PHP itself.  For a
list of more appropriate places to ask for help using PHP, please
visit http://www.php.net/support.php as this bug system is not the
appropriate forum for asking support questions.  Due to the volume
of reports we can not explain in detail here why your report is not
a bug.  The support channels will be able to provide an explanation
for you.

Thank you for your interest in PHP.

Your reproduction case isn't really clear, but this seems to work as expected 
for me.


Previous Comments:
------------------------------------------------------------------------
[2013-01-21 13:11:04] dirk dot gerigk at atraveo dot de

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.


------------------------------------------------------------------------



-- 
Edit this bug report at https://bugs.php.net/bug.php?id=64036&edit=1

Reply via email to