Call backs to user function
| From: | Peter Bowen | Date: | Sun, 18 Jun 2000 23:24:02 +0000 |
| Subject: | Call backs to user function | ||
| Groups: | php.dev | ||
| Request: | Send a blank email to php-dev+get-21701@lists.php.net to get a copy of this message | ||
I am having trouble figuring out whether PHP copies classes or uses
references when passing them.
I have a class, foo, that in its constructor creates an object cb of class
string_callback. I then call methods in cb with $this as one of the
parameters. Later, when cb tries to call a method in foo it doesn't set
the instance variables properly.
The code for both foo and string_callback is attached. Normally, a php
script opens a text file for reading. Then an object of type foo is
created by calling:
$bar = new foo($fh);
where $fh is the handle to the open file.
When I do this the $bar->status is not sticking. I is always an empty
string after a callback.
If anyone can explain this problem, I would very much appreciate it.
Thanks.
Peter Bowen
pzb@lightningcast.net