Skip to main content

Questions tagged [php-internals]

How the PHP programming language works underneath, and questions about the underlying C code.

2282 votes
7 answers
459k views

How does PHP 'foreach' actually work?

Let me prefix this by saying that I know what foreach is, does and how to use it. This question concerns how it works under the bonnet, and I don't want any answers along the lines of "this is how you ...
DaveRandom's user avatar
  • 88.4k
52 votes
2 answers
3k views

Parentheses altering semantics of function call result

It was noted in another question that wrapping the result of a PHP function call in parentheses can somehow convert the result into a fully-fledged expression, such that the following works: <?php ...
Lightness Races in Orbit's user avatar
19 votes
7 answers
3k views

print_r() adds properties to DateTime objects [duplicate]

Consider the following code sample: $m_oDate = new DateTime('2013-06-12 15:54:25'); print_r($m_oDate); echo $m_oDate->date; Since PHP 5.3, this produces (something like) the following output: ...
C-H-a-P's user avatar
  • 217
43 votes
6 answers
6k views

Why don't PHP attributes allow functions?

I'm pretty new to PHP, but I've been programming in similar languages for years. I was flummoxed by the following: class Foo { public $path = array( realpath(".") ); } It produced a ...
Schwern's user avatar
  • 161k
27 votes
5 answers
7k views

Detecting whether a PHP variable is a reference / referenced

Is there a way in PHP to determine whether a given variable is a reference to another variable and / or referenced by another variable? I appreciate that it might not be possible to separate ...
borrible's user avatar
  • 17.3k
133 votes
41 answers
187k views

What does "zend_mm_heap corrupted" mean

All of the sudden I've been having problems with my application that I've never had before. I decided to check the Apache's error log, and I found an error message saying "zend_mm_heap corrupted". ...
bkulyk's user avatar
  • 1,694
13 votes
2 answers
4k views

What is #<some-number> next to object(someClass) in var_dump of an object? I have an inference. Am I right?

This is the code & its output I used to draw the inference below: class a { public $var1; public $var2; } $obj0 = new a; var_dump($obj0); class b { public $var1; public $...
ThinkingMonkey's user avatar
26 votes
5 answers
10k views

How are associative arrays implemented in PHP?

Can someone explain how PHP implements associative arrays? What underlying data structure does PHP use? Does PHP hash the key and store it in some kind of hash map? I am curious because I was ...
user avatar
15 votes
3 answers
15k views

Getting Started with PHP Extension-Development [closed]

Please suggest help articles or tutorials about PHP "low" level С-modules programming interface.
duganets's user avatar
  • 1,893
31 votes
4 answers
7k views

Where can I learn about PHP internals? [closed]

What are good resources to start learning the internals of PHP and the Zend Engine?
Adam Ramadhan's user avatar
2 votes
1 answer
254 views

Why does a PHP array get modified when it's element is reference-assigned?

When ref-assigning an array's element, the contents of the array are modified: $arr = array(100, 200); var_dump($arr); /* shows: array(2) { [0]=> int(100) // ← ← ← int(100) [1]=> int(...
Pacerier's user avatar
  • 88.6k
22 votes
4 answers
4k views

How does PHP memory actually work

I've always heard and searched for new php 'good writing practice', for example: It's better (for performance) to check if array key exists than search in array, but also it seems better for memory ...
George G's user avatar
  • 7,639
21 votes
3 answers
11k views

Reading Zend Engine API code: What does ## (double hash) mean?

Out of curiousity, I'm reading the Zend Engine API code and encountered quite a number of ## in their #define's. For example, at /usr/lib/php5/Zend/zend_API.h: #define ZEND_FN(name) zif_##name #...
Seh Hui Leong's user avatar
12 votes
1 answer
4k views

How does PHP assign and free memory for variables?

I was wondering when does PHP free the memory which is used for a variables for example function foo(){ $foo = 'data'; return $foo; // <- is the memory space for `$foo` emptied at this point?...
Alex's user avatar
  • 67.5k
6 votes
8 answers
3k views

Compare PHP Arrays Using Memory References

Is it possible to see if two array variables point to the same memory location? (they are the same array)
Kirk Ouimet's user avatar
  • 28.1k

15 30 50 per page