[PHP] struct zend_guard

2012-01-30 Thread Adi Mutu
Hello,

Can anybody tell me what this struct is used for ?
I'm new to the internals of php.

Thanks,
A


Re: [PHP] Strange foreach reference issue

2012-01-08 Thread Adi Mutu
You can see here some nice pics, it's exactly as you said.

http://schlueters.de/blog/archives/141-References-and-foreach.html




 From: Tim Behrendsen t...@behrendsen.com
To: php-general@lists.php.net 
Cc: Stephen stephe...@rogers.com; Matijn Woudt tijn...@gmail.com 
Sent: Sunday, January 8, 2012 3:01 AM
Subject: Re: [PHP] Strange foreach reference issue
 
On 1/7/2012 4:44 PM, Stephen wrote:
 On 12-01-07 07:30 PM, Tim Behrendsen wrote:
 
 When you use an ampersand on the variable, that creates a reference to the 
 array elements, allowing you to potentially change the array elements 
 themselves (which I'm not doing here).
 
 http://www.php.net/manual/en/control-structures.foreach.php
 
 I do notice in the manual that it says, Reference of a $value and the last 
 array element remain even after the foreach loop. It is recommended to 
 destroy it by unset(). But that doesn't really explain why it contaminates 
 the next foreach loop in such an odd way. You would think that the $row in 
 the second loop would be assigned a non-reference value.
 
 Tim
 
 Tim,
 
 You are using the $variable in an unintended (by PHP designers), and I 
 suggest undefined manner.
 
 So the outcome cannot, but definition be explained.
 
 Was this intended, and what were you trying to accomplish?
 
 Stephen

In the real code, I just happen to use the same variable name first as a 
reference, and then as a normal non-reference, and was getting the mysterious 
duplicate rows.

I think I'm using everything in a completely reasonable way; the second foreach 
is reassigning the loop variable. Nothing that comes before using that variable 
ought to cause undefined behavior. The warning in the manual is about using the 
loop variable as a reference after exiting the loop, but I'm not doing that. 
I'm reassigning it, exactly as if I just decided to do a straight assignment of 
$row

Ah ha, wait a minute, that's the key. OK, this is making more sense.

The first loop is leaving a reference to the final element. But then the second 
foreach is doing a straight assignment to the $row variable, but $row is a 
reference to the final element. So the foreach is assigning its iterated value 
to the final element of the array, instead of a normal variable.

OK, I understand the logic now. The world now makes sense. The moral is always 
unset the iterator variable when doing foreach with a reference, like the 
manual says. :)

Thanks for everyone's help.

Tim

-- PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

[PHP] questions from page Reference Counting Basics

2012-01-08 Thread Adi Mutu


Hello,

I was reading http://www.php.net/manual/en/features.gc.refcounting-basics.php, 
and i saw this:

The xdebug_debug_zval() function does not show this, but you could see it by 
also displaying the memory pointer.

My question is, how can you get the memory pointer of a php variable? 

Thanks,
A.

RE: [PHP] Zend memory manager

2011-01-24 Thread Adi Mutu

I have asked also there..but no answerBut honestly i don't understand 
why you have reccomended me that forum..because i thougt these mailing 
lists are about php developing...
Thanks,A.


  

[PHP] Zend Memory Manager

2011-01-23 Thread Adi Mutu


Hello,

This is my first mail here, i hope it's ok.
Can somebody give me any hint to some docs about how the Zend mm works? I can't 
find any references on the net.
I'm not interested in only emalloc, efree etc. but at an even lower level  i 
mean about functions like _zend_mm_alloc_int, _zend_mm_alloc_int
and structs like zend_mm_heap.

Thanks,
A.


  

[PHP] Zend memory manager

2011-01-23 Thread Adi Mutu
Hello,

This is my first mail here, i hope it's ok.
Can somebody give me any hint to some docs about how the Zend mm works? I can't 
find any references on the net.
I'm not interested in only emalloc, efree etc. but at an even lower level  i 
mean about functions like _zend_mm_alloc_int, _zend_mm_alloc_int
and structs like zend_mm_heap.

Thanks,
A.


  

Re: [PHP] Zend memory manager

2011-01-23 Thread Adi Mutu


I have looked at the sources, but it's still not very clear to me
Where should I ask this question than.?

Sorry for the inconveniences!
Thanks,



  

Re: [PHP] Zend memory manager

2011-01-23 Thread Adi Mutu
Of course I have tried, but nothing ...
The results or only aboyt  emalloc/pemalloc familly.
Nothing lower level about how these 2 functions are implemented or about the 
mm_heap struct of mm_block.