Resources are the traditional approach for mapping an arbitrary pointer to PHP space, managing its lifetime safely.
PHP 5 OO support allows for similar things, but maps the pointer as a PHP object. They're similar in some ways, but different in others. The biggest functional difference (aside from OO) is that you can't create persistent objects (ala mysql_pconnect())--you have to use resources for that. It's usually faster to write a procedural extension using resources than it is to write an OO extension using PHP 5 objects, although the latter can be more accessible to the consumers of your extension. Resources: work with PHP 4. Can be persistent. Objects: work with PHP 5 and up. There is no hard and fast rule about which one you choose; just use the one the makes most sense for the task at hand. --Wez. On 4/30/06, Brandon Fosdick <[EMAIL PROTECTED]> wrote:
From the point of view of an extension, what's the difference between a resource and an object? Is there any reason to favor one over the other? sqlite seems to use resources for the procedural interface and objects otherwise. Whereas mysqli uses objects all around in user space, but then maps them to resources in the background. Why use objects only to map them to resources? Are resources somehow special? -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php
-- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php