Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:45655 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 10449 invoked from network); 2 Oct 2009 15:46:21 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 2 Oct 2009 15:46:21 -0000 Authentication-Results: pb1.pair.com smtp.mail=israelekpo@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=israelekpo@gmail.com; sender-id=pass; domainkeys=bad Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.220.225 as permitted sender) DomainKey-Status: bad X-DomainKeys: Ecelerity dk_validate implementing draft-delany-domainkeys-base-01 X-PHP-List-Original-Sender: israelekpo@gmail.com X-Host-Fingerprint: 209.85.220.225 mail-fx0-f225.google.com Received: from [209.85.220.225] ([209.85.220.225:62915] helo=mail-fx0-f225.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id F9/22-32165-B4026CA4 for ; Fri, 02 Oct 2009 11:46:20 -0400 Received: by fxm25 with SMTP id 25so1232239fxm.24 for ; Fri, 02 Oct 2009 08:46:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:in-reply-to:references :date:message-id:subject:from:to:cc:content-type; bh=QqdbLbi9gpgkunV+sVKp60pPvgIbsRHi1Q29FG1U1kg=; b=fFukv9DK+2txasSx76LZt2E5qcXWU6r1tnct6QfCtnW1mcq9OFbo9UmSZ8G8/e3gRb 9SoxWIfpSvadmWmUB+GeqP1bEATsthwoTIES1jxucGxVSM4A+IkBz+PpAh5fc9A9QSRJ Es+wGwfiitpgll0SnRZOvqg39kttiamIwpmh8= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; b=Y4BE2uFVgiaIefwgA45fVwO7PwCvOD0FWy0mF1jBQ3ABqJZuayBKhwRr652bXbj/98 UAXPHSjJ/+NQK16g5zjxbpm5OJV5RSbfhC0TrSKw0yUXPY3TKsFsBy+7vV+jqU1+v+sB wd+I8+UHkKcrn8d3f+88wCHv0NcMq0DIlJtw4= MIME-Version: 1.0 Received: by 10.86.231.15 with SMTP id d15mr2449070fgh.74.1254498376770; Fri, 02 Oct 2009 08:46:16 -0700 (PDT) In-Reply-To: <4AC61244.7020202@planetavent.de> References: <4AC5A4A6.5060106@easyflirt.com> <4AC61244.7020202@planetavent.de> Date: Fri, 2 Oct 2009 11:46:16 -0400 Message-ID: To: Nicolai Scheer Cc: Mathieu Suen , internals@lists.php.net Content-Type: multipart/alternative; boundary=0014852f57801e660d0474f5aa75 Subject: Re: [PHP-DEV] Doc on the VM From: israelekpo@gmail.com (Israel Ekpo) --0014852f57801e660d0474f5aa75 Content-Type: text/plain; charset=UTF-8 On Fri, Oct 2, 2009 at 10:46 AM, Nicolai Scheer wrote: > Hi! > > Mathieu Suen schrieb: > > Hi, > > > > I would like to know if there is some documentation on the different > > layout of the array, object varaible ... in php. > > Or were in the source can we read how the php VM reprensent those > entites? > > At first, you should have a look at Zend/zend.h in the php source tree. > There you'll find the definition of a "php variable", the zval struct: > > struct _zval_struct { > /* Variable information */ > zvalue_value value; /* value */ > zend_uint refcount__gc; > zend_uchar type; /* active type */ > zend_uchar is_ref__gc; > }; > > The content of the variable is: > > typedef union _zvalue_value { > long lval; /* long value */ > double dval; /* double value */ > struct { > char *val; > int len; > } str; > HashTable *ht; /* hash table value */ > zend_object_value obj; > } zvalue_value; > > Since a php variable can contain any type php has to offer, this > representation was choosen in order to simplify access on the internal > side. > > There's a bunch of macros for creating zvals, getting/setting > types/values, etc. so you don't need to do this by hand (of course, in > complex cases you have to). > > Does this help? > > greetings, > > Nico > > > -- > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: http://www.php.net/unsub.php > > Hello, As Mathieu advised, taking a look at some of the source code would be very helpful You should also take a look at these files in the Zend folder of the PHP source: zend_object_handlers.c zend_object_handlers.h zend_objects.c zend_objects.h zend_objects_API.c zend_objects_API.h After that, I would advice that you grab a copy of Sara Golemon's book. It was really helpful to me as well. *http://www.amazon.com/Extending-Embedding-PHP-Sara-Golemon/dp/067232704X* One similarity between arrays and objects is that they both use the HashTable type to store their elements (for arrays) and properties (for objects). For objects (classes), however the class has to be made available during the MINIT phase whereas for arrays that is not needed. There are other similarities and differences but Sara Goleman's book will definitely give you a head start and then you can figure out the rest as you practice. There are also differences between PHP 5.2 and 5.3, they use fifferent versions of the Zend Engine (2.2 and 2.3 respectively) some members of the zval struct have changed and you will need to use the macros to access some of the members of these structs for compatibility reasons. -- "Good Enough" is not good enough. To give anything less than your best is to sacrifice the gift. Quality First. Measure Twice. Cut Once. --0014852f57801e660d0474f5aa75--