Yii Framework Forum: Internals of PHP references - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Internals of PHP references How are values stored and retrieved on low level? Rate Topic: -----

#1 User is offline   jodev 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 75
  • Joined: 10-January 11
  • Location:The Netherlands

Posted 24 May 2012 - 10:27 AM

Hi all,

I'm trying to broaden my PHP knowledge and in doing so I have been looking into the workings of references on variables. I know that values are stored in C zval structure that contains fields for determining if the value is a reference value and how many references is has got. I also know that the actual value is stored in a C union.

What I'm not quite sure about however is how a PHP variable gets or sets a value through the zval structure. Here is how I understand what happens when a variable is initialized. PHP allocated space in memory, creates a zval structure and stores information about the newly assigned value into a union that is than pointed to from the zval struct. But how does PHP actually go about retrieving the value from memory? How does PHP exactly know that a certain zval structure is tied to a certain variable? Does the variable hold a pointer value that points to the struct? And if so, how are those pointer values stored in memory?

Anybody who can shine a light on this? Thanks in advance!
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users