From:             kn1g at yahoo dot com dot br
Operating system: Linux
PHP version:      4.4.4
PHP Bug Type:     Class/Object related
Bug description:  class_exists strange behaviour

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 bug report at http://bugs.php.net/?id=38504&edit=1
-- 
Try a CVS snapshot (PHP 4.4): 
http://bugs.php.net/fix.php?id=38504&r=trysnapshot44
Try a CVS snapshot (PHP 5.2): 
http://bugs.php.net/fix.php?id=38504&r=trysnapshot52
Try a CVS snapshot (PHP 6.0): 
http://bugs.php.net/fix.php?id=38504&r=trysnapshot60
Fixed in CVS:                 http://bugs.php.net/fix.php?id=38504&r=fixedcvs
Fixed in release:             
http://bugs.php.net/fix.php?id=38504&r=alreadyfixed
Need backtrace:               http://bugs.php.net/fix.php?id=38504&r=needtrace
Need Reproduce Script:        http://bugs.php.net/fix.php?id=38504&r=needscript
Try newer version:            http://bugs.php.net/fix.php?id=38504&r=oldversion
Not developer issue:          http://bugs.php.net/fix.php?id=38504&r=support
Expected behavior:            http://bugs.php.net/fix.php?id=38504&r=notwrong
Not enough info:              
http://bugs.php.net/fix.php?id=38504&r=notenoughinfo
Submitted twice:              
http://bugs.php.net/fix.php?id=38504&r=submittedtwice
register_globals:             http://bugs.php.net/fix.php?id=38504&r=globals
PHP 3 support discontinued:   http://bugs.php.net/fix.php?id=38504&r=php3
Daylight Savings:             http://bugs.php.net/fix.php?id=38504&r=dst
IIS Stability:                http://bugs.php.net/fix.php?id=38504&r=isapi
Install GNU Sed:              http://bugs.php.net/fix.php?id=38504&r=gnused
Floating point limitations:   http://bugs.php.net/fix.php?id=38504&r=float
No Zend Extensions:           http://bugs.php.net/fix.php?id=38504&r=nozend
MySQL Configuration Error:    http://bugs.php.net/fix.php?id=38504&r=mysqlcfg

Reply via email to