note 61388 added to language.oop
| From: | Wolverine at osu1 dot php dot net | Date: | Thu, 02 Feb 2006 05:30:26 +0000 |
| Subject: | note 61388 added to language.oop | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-102856@lists.php.net to get a copy of this message | ||
In case you would like to interrupt object construction on some condition and return false for
further checking:
<?php
class Foo
{
// Constructor
function Foo()
{
/* Some inits here */
$someval=false;
if ($someval===false)
{
return false;
}
}
}
$obj=new Foo(); // This won't work and will return partially initialised object instead of
false
class Bar
{
// Constructor
function Bar()
{
/* Some inits here */
$someval=false;
if ($someval===false)
{
$this=false;
return;
}
}
}
$obj2=new Bar(); // This will work as expected and return false
?>
Hope this helps some people.
----
Server IP: 195.136.184.34
Probable Submitter: 213.25.213.102
----
Manual Page -- http://www.php.net/manual/en/language.oop.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+61388
Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+61388&report=yes&reason=added+to+the+manual
Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+61388&report=yes&reason=bad+code
Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+61388&report=yes&reason=spam
Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+61388&report=yes&reason=useless
Delete: non-english -- http://master.php.net/manage/user-notes.php?action=delete+61388&report=yes&reason=non-english
Delete: already in docs -- http://master.php.net/manage/user-notes.php?action=delete+61388&report=yes&reason=already+in+docs
Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+61388&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+61388&report=yes
Search -- http://master.php.net/manage/user-notes.php