note 65176 added to language.oop5
| From: | php-general at lists dot php dot net | Date: | Wed, 26 Apr 2006 02:53:18 +0000 |
| Subject: | note 65176 added to language.oop5 | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-109718@lists.php.net to get a copy of this message | ||
<?php
if (class_exists("cl_test")) return;
echo "ppppp";
class cl_test{
function cl_test(){
echo "quirky...";
}
} // class definition ends
?>
although the logic is clear php treats the above code differently. PHP translates it to:
class cl_test{
function cl_test(){
echo "quirky...";
}
} // class definition ends
if (class_exists("cl_test")) return;
echo "ppppp";
If you must have the previous logic to work you are forced to have the following code:
if (!class_exists("cl_test")) {
echo "ppppp";
class cl_test{
function cl_test(){
echo "quirky...";
}
} // class definition ends
}
----
Server IP: 66.163.161.117
Probable Submitter: 210.213.129.240
----
X-Spam-Status: No, hits=3.1 required=5.0 tests=DATE_MISSING,FROM_NO_LOWER
autolearn=no version=2.64
----
Manual Page -- http://www.php.net/manual/en/language.oop5.php
Edit -- http://master.php.net/note/edit/65176
Del: integrated -- http://master.php.net/note/delete/65176/integrated
Del: useless -- http://master.php.net/note/delete/65176/useless
Del: bad code -- http://master.php.net/note/delete/65176/bad+code
Del: spam -- http://master.php.net/note/delete/65176/spam
Del: non-english -- http://master.php.net/note/delete/65176/non-english
Del: in docs -- http://master.php.net/note/delete/65176/in+docs
Del: other reasons-- http://master.php.net/note/delete/65176
Reject -- http://master.php.net/note/reject/65176
Search -- http://master.php.net/manage/user-notes.php