Re: PHP 4.0 Bug #2430 Updated: memory leaks in zend
| From: | Danny Heijl | Date: | Wed, 06 Oct 1999 21:22:22 +0000 |
| Subject: | Re: PHP 4.0 Bug #2430 Updated: memory leaks in zend | ||
| References: | 1 | Groups: | php.dev |
| Request: | Send a blank email to php-dev+get-11584@lists.php.net to get a copy of this message | ||
Sorry, but the tests on classes now fail instead :
The simple class test (classes/class-example.php3) :
<?php
/* pretty nifty object oriented code! */
class user {
var $first_name,$family_name,$address,$phone_num;
cfunction display()
{
echo "User information\n";
echo "----------------\n\n";
echo "First name:\t ".$this->first_name."\n";
echo "Family name:\t ".$this->family_name."\n";
echo "Address:\t ".$this->address."\n";
echo "Phone:\t\t ".$this->phone_num."\n";
echo "\n\n";
}
cfunction initialize($first_name,$family_name,$address,$phone_num)
{
$this->first_name = $first_name;
$this->family_name = $family_name;
$this->address = $address;
$this->phone_num = $phone_num;
}
};
function test($u)
{ /* one can pass classes as arguments */
$u->display();
$t = $u;
$t->address = "New address...";
return $t; /* and also return them as return values */
}
$user1 = new user;
$user2 = new user;
$user1->initialize("Zeev","Suraski","Ben Gourion 3, Kiryat Bialik,
Israel","+972-4-8713139");
$user2->initialize("Andi","Gutmans","Haifa,
Israel","+972-4-8231621");
$user1->display();
$user2->display();
$tmp = test($user2);
$tmp->display();
?>
now gives the following result :
**********************************************************
Content-Type: text/html
<br>
<b>Fatal error</b>: Call to a member function on a non-object
in <b>cl1.php3</b> on line <b>40</b><br>
***********************************************************
And the class inheritance test (classes/inheritance.php3) :
<?php
/* Inheritance test. Pretty nifty if I do say so myself! */
class foo {
var $a;
var $b;
cfunction display() {
echo "This is class foo\n";
echo "a = ".$this->a."\n";
echo "b = ".$this->b."\n";
}
cfunction mul() {
return $this->a*$this->b;
}
};
class bar extends foo {
var $c;
cfunction display() { /* alternative display function for class bar */
echo "This is class bar\n";
echo "a = ".$this->a."\n";
echo "b = ".$this->b."\n";
echo "c = ".$this->c."\n";
}
};
$foo1 = new foo;
$foo1->a = 2;
$foo1->b = 5;
$foo1->display();
echo $foo1->mul()."\n";
echo "-----\n";
$bar1 = new bar;
$bar1->a = 4;
$bar1->b = 3;
$bar1->c = 12;
$bar1->display();
echo $bar1->mul()."\n";
?>
gives the following result :
***********************************************************
Content-Type: text/html
This is class foo
a = 2
b = 5
<br>
<b>Fatal error</b>: Call to a member function on a non-object
in <b>cl2.php3</b> on line <b>33</b><br>
***********************************************************
Danny
---
Bug Datbase wrote:
>
> ID: 2430
> Updated by: andi
> Reported By: Danny.Heijl@cevi.be
> Status: Closed
> Bug Type: Scripting Engine problem
> Assigned To:
> Comments:
>
> I have fixed this leak. Please update your CVS tree and see if it's OK.
> Thanks for the report.
>
> Full Bug description available at:
> http://bugs.php.net/version4/?id=2430