note 59429 deleted from language.oop5.basic by colder
| From: | colder@php.net | Date: | Sun, 19 Aug 2007 23:41:26 +0000 |
| Subject: | note 59429 deleted from language.oop5.basic by colder | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-129613@lists.php.net to get a copy of this message | ||
Note Submitter: mrich at runbox dot removethis dot com
----
PHP 4.3.10:
<?php
class foo {
var $what;
function foo($newWhat = 'foo') {
$this->what = $newWhat;
}
function bar() {
print "<p>I'm a ".$this->what."</p>\n";
}
}
$var = 'foo';
$obj = new $var;
// prints "I'm a foo"
$obj->bar();
$obj = new $var();
// prints "I'm a foo"
$obj->bar();
$obj = new $var('bar');
// prints "I'm a bar"
$obj->bar();
?>