Re: resources vs objects?

From: Date: Sun, 30 Apr 2006 18:26:59 +0000
Subject: Re: resources vs objects?
References: 1 2  Groups: php.internals 
Request: Send a blank email to internals+get-23055@lists.php.net to get a copy of this message
Wez Furlong wrote:
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.
ah, much clearer now, thanks.

« previous php.internals (#23055) next »