Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:23052 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 26446 invoked by uid 1010); 30 Apr 2006 13:31:20 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 26431 invoked from network); 30 Apr 2006 13:31:19 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 30 Apr 2006 13:31:19 -0000 X-PHP-List-Original-Sender: kingwez@gmail.com X-Host-Fingerprint: 64.233.166.179 pproxy.gmail.com Linux 2.4/2.6 Received: from ([64.233.166.179:43821] helo=pproxy.gmail.com) by pb1.pair.com (ecelerity 2.0 beta r(6323M)) with SMTP id BF/3E-18514-62CB4544 for ; Sun, 30 Apr 2006 09:31:18 -0400 Received: by pproxy.gmail.com with SMTP id 57so2923813pya for ; Sun, 30 Apr 2006 06:31:15 -0700 (PDT) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=pdpRoN/9nmOWrAdAwLCJGQP0TOkRvikLLK+47CXDlw751dZ+uDPwtBLf0U/u5aVHklAKSJtcrmWBxGyXb6W2Q2yGKdq0e6cJ02UgS37Qjw5V3nQTkJBBREp6mBfRYVcSsdA9PamZErhVqqJ6GJ0q8sQIQJMC9Skm2tvtfXUoQAM= Received: by 10.35.96.11 with SMTP id y11mr1751665pyl; Sun, 30 Apr 2006 06:31:15 -0700 (PDT) Received: by 10.35.41.17 with HTTP; Sun, 30 Apr 2006 06:31:14 -0700 (PDT) Message-ID: <4e89b4260604300631j6f855a59wc008cc320ff8f48f@mail.gmail.com> Date: Sun, 30 Apr 2006 09:31:15 -0400 To: "Brandon Fosdick" Cc: internals@lists.php.net In-Reply-To: <445447FB.5060306@bfoz.net> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: quoted-printable Content-Disposition: inline References: <445447FB.5060306@bfoz.net> Subject: Re: [PHP-DEV] resources vs objects? From: kingwez@gmail.com ("Wez Furlong") 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 wrote: > From the point of view of an extension, what's the difference between a r= esource and an object? Is there any reason to favor one over the other? > > sqlite seems to use resources for the procedural interface and objects ot= herwise. Whereas mysqli uses objects all around in user space, but then map= s 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 > >