Sr. Web Developer
mediabistro.com
US-NY-New York

Justtechjobs.com Post A Job | Post A Resume

Comments for: stump20021223.php3

Message # 1016275:
Date: 04/26/03 02:51
By: Stevenv Vasilogianis
Subject: One (more) small flaw

> function Base()
> {
> $this->PEAR();
>
> if(get_class($this) == 'base')
> {
> $this = new PEAR_Error('Base is an abstracted class!');
> }
> else
> {
> $this->db =& DB::connect(BASE_PEAR_DSN,true);
> if(DB::isError($this->db))
> {
> $this = new PEAR_Error($this->db->getMessage());

This (last quoted line) will cause the destructor to stop working,
because $this is no longer a class which contains a _{class name}
method. Instead, it is a PEAR_Error object. Here's some proof:

<?php

require_once('PEAR.php');

class foo extends PEAR {
function foo ( ) {
$this -> PEAR();
echo "Hello from The Contructor\n";
$this = new PEAR_Error('');
}

function _foo ( ) {
echo "Hello from The Destructor\n";
}
}

$foo =& new foo;
?>

Gives the ouput:
Hello from The Contructor

However, removing the line which reassigns $this to a PEAR_Error
object produces the expected output:

Hello from The Constructor
Hello from The Destructor

HTH

Previous Message | Next Message


Comments:
One (more) small flawStevenv Vasilogianis04/26/03 02:51
RE: PHPLIB vs. PEARDavid Grinberg02/06/03 22:59
One small flawWouter Roosendaal02/01/03 12:04
PHP Manual "Classes and Objects"daniel @drian keeney01/31/03 23:58
PHPLIB vs. PEARRichard Ruiter01/25/03 08:24
DB InconsistencyMark Tudor01/21/03 18:20
DB InconsistencyMark Tudor01/21/03 18:20
 

If you are looking for help, please post on the appropriate forum here. Your questions will be answered much more quickly.

Add A Comment:

Name:

Email:

Subject:

Message:

To reduce spam posts, messages are now manually approved

You are not [logged in]. That means your account will not get credit for this post.