|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2006-08-18 20:38 UTC] tony2001@php.net
[2006-08-19 02:45 UTC] kn1g at yahoo dot com dot br
[2006-08-21 08:26 UTC] tony2001@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Wed Dec 03 16:00:01 2025 UTC |
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