From:             [EMAIL PROTECTED]
Operating system: Linux web13.90.ha.ovh.net 2.4.20
PHP version:      4.3.0
PHP Bug Type:     Class/Object related
Bug description:  Incorrect fatal error when calling a method on a class from within a 
function

PHPInfo for the server is here : http://90plan.ovh.net/phpinfo.php

The code is here :
<pre>
<?php
class Toto
{
        var $port;

        function Toto($string)
        {
                $this->port=$string;
                echo "<br><br>TOTO constructor was called so class was found!! Dumping
vars:<br><i>";
                var_dump($this);
                echo"</i><br>";
        }
        
        function test()
        {
                echo "<br><br><b>method <i>test</i> called.</b> Value for port is
:".$this->port;
        }
}

        $toutou=new Toto("PORT1");
        $toutou->test();
        echo "<hr>Entering function and doing the same calls with value PORT2";
        testCallsInFunction();

function testCallsInFunction()
{

        $toutou2=new Toto("PORT2");
        $toutou->test();
}
?></pre>

The output I get is 
<pre>
TOTO constructor was called so class was found!! Dumping vars:
object(toto)(1) { ["port"]=> string(5) "PORT1" } 


method test called. Value for port is :PORT1
--------------------------------------------------------------------------------
Entering function and doing the same calls with value PORT2

TOTO constructor was called so class was found!! Dumping vars:
object(toto)(1) { ["port"]=> string(5) "PORT2" } 

Fatal error: Call to a member function on a non-object in
/home/eurobill/www/toto.php on line 29
</pre>

I have tried including the class in another file and adding an include
statement inside the function but it still doesn't work. This bug forced
me to remove calls to objects in functions for my site !
-- 
Edit bug report at http://bugs.php.net/?id=22241&edit=1
-- 
Try a CVS snapshot:         http://bugs.php.net/fix.php?id=22241&r=trysnapshot
Fixed in CVS:               http://bugs.php.net/fix.php?id=22241&r=fixedcvs
Fixed in release:           http://bugs.php.net/fix.php?id=22241&r=alreadyfixed
Need backtrace:             http://bugs.php.net/fix.php?id=22241&r=needtrace
Try newer version:          http://bugs.php.net/fix.php?id=22241&r=oldversion
Not developer issue:        http://bugs.php.net/fix.php?id=22241&r=support
Expected behavior:          http://bugs.php.net/fix.php?id=22241&r=notwrong
Not enough info:            http://bugs.php.net/fix.php?id=22241&r=notenoughinfo
Submitted twice:            http://bugs.php.net/fix.php?id=22241&r=submittedtwice
register_globals:           http://bugs.php.net/fix.php?id=22241&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=22241&r=php3
Daylight Savings:           http://bugs.php.net/fix.php?id=22241&r=dst
IIS Stability:              http://bugs.php.net/fix.php?id=22241&r=isapi
Install GNU Sed:            http://bugs.php.net/fix.php?id=22241&r=gnused

Reply via email to