classes
| From: | Kevin Waterson | Date: | Wed, 05 Feb 2003 21:24:59 +0000 |
| Subject: | classes | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-134492@lists.php.net to get a copy of this message | ||
I am having my constructor execute twice..
Why is this?
class a looks like this...
<?php
class a {
function __construct(){
echo 'construct';
$this->my_method();
}
function my_method(){
include ("classb.php");
$blah = new b;
echo $blah -> class_b_method();
}
}
// instantiate new object
$page = new a;
?>
classb looks like this
<?php
class b extends a{
function class_b_method(){
$var = 'This is Classb';
return $var;
}
}
?>
--
______
(_____ \
_____) ) ____ ____ ____ ____
| ____/ / _ ) / _ | / ___) / _ )
| | ( (/ / ( ( | |( (___ ( (/ /
|_| \____) \_||_| \____) \____)
Kevin Waterson
Port Macquarie, Australia