#22241 [Fbk->Opn]: Incorrect fatal error when calling a method on a class from within a function
| From: | philippe-php at girolami dot org | Date: | Sun, 16 Feb 2003 17:06:01 +0000 |
| Subject: | #22241 [Fbk->Opn]: Incorrect fatal error when calling a method on a class from within a function | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-33283@lists.php.net to get a copy of this message | ||
ID: 22241
User updated by: philippe-php@girolami.org
Reported By: philippe-php@girolami.org
-Status: Feedback
+Status: Open
Bug Type: Class/Object related
Operating System: Linux web13.90.ha.ovh.net 2.4.20
PHP Version: 4.3.0
New Comment:
I do not have root access on the server as this is a shared server.
Perhaps someone else can try
Previous Comments:
------------------------------------------------------------------------
[2003-02-16 10:29:38] iliaa@php.net
Please try using this CVS snapshot:
http://snaps.php.net/php4-STABLE-latest.tar.gz
For Windows:
http://snaps.php.net/win32/php4-win32-STABLE-latest.zip
------------------------------------------------------------------------
[2003-02-16 06:17:10] philippe-php@girolami.org
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 this bug report at http://bugs.php.net/?id=22241&edit=1