ID:               38504
 Updated by:       [EMAIL PROTECTED]
 Reported By:      kn1g at yahoo dot com dot br
 Status:           Bogus
 Bug Type:         Class/Object related
 Operating System: Linux
 PHP Version:      4.4.4
 New Comment:

You can always add a note youself.


Previous Comments:
------------------------------------------------------------------------

[2006-08-19 02:45:09] kn1g at yahoo dot com dot br

I see, well, I think that class_exists function manual could have a
note warning about this (I didn't find this information anywhere).

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

[2006-08-18 20:38:56] [EMAIL PROTECTED]

Classes are declared during the compile time.
So the class DOES exist and when you actually run the code, the if
condition evaluates to TRUE, hence return is executed.
This is expected behaviour.

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

[2006-08-18 18:27:15] kn1g at yahoo dot com dot br

Description:
------------
class_exists with return appears to avoid setting a variable after a
class definition.

Avoiding the return  inside the if block like work as expected:
<?
if(!class_exists('newclass')){
 class newclass(){
 }
}
$var_newclass = "newclass ok\n";
?>

But I couldn't find anything in the documentation explaining this
behaviour.

Reproduce code:
---------------
"class.php"
<?
if(class_exists('newclass')){
    return;
}
class newclass{
    function newclass(){
        echo "hi\n";
    }
}
$var_newclass = "newclass ok\n";
?>

"test.php"
<?
include("class.php");
new newclass;
echo $var_newclass;
?>

Expected result:
----------------
hi
newclass ok


Actual result:
--------------
hi


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


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

Reply via email to