get_property_ptr
| From: | Sterling Hughes | Date: | Sun, 18 May 2003 20:27:21 +0000 |
| Subject: | get_property_ptr | ||
| Groups: | php.internals | ||
| Request: | Send a blank email to internals+get-1683@lists.php.net to get a copy of this message | ||
hey,
I'm working on simplexml (sources available in pecl), and I want it to
work in a foreach() loop without requiring the use of a temporary
variable, ie:
books.xml
<books>
<book>
<title>The Grapes of Wrath</title>
<author>John Steinbeck</author>
</book>
<book>
<title>The Pearl</title>
<author>John Steinbeck</author>
</book>
</books>
books.php
<?php
$books = simplexml_load_file('books.xml');
$booklist = $books->book; // must assign to a temporary variable
foreach ($booklist as $book) {
echo "{$book->title}\n";
}
?>
So I'm trying to figure out how to use the get_property_ptr callback.
I've tried a few things:
1) zend_object_create_proxy. The docs say I can just return a proxy
object, however, this causes a segfault for me:
return zend_object_create_proxy(object, member TSRMLS_CC);
2) Adding indirection. I just call property_read, and then return a
pointer to the result of the property_read call. This also yields a
segfault.
So, any insights on how I might be a smarter boy, and actually get this
thingy to work? :)
-Sterling
--
"Whether you think you can or think you can't -- you are right."
- Henry Ford