Questions tagged [php-internals]

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

PHP Internals

Tag purpose

The purpose of the tag is to indicate a question about the internals of PHP. Possible questions could be about how references counting or copy on write. E.g. When you want to know what happens under the hood while doing things in PHP. It can also be applied to questions in the tag that deal with extending PHP at the core. This tag should also be used for any questions about the Zend Engine powering PHP.


External Links

265 questions
2126
votes
7 answers

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 loop an array with foreach". For a long time I…
DaveRandom
  • 84,004
  • 11
  • 142
  • 168
128
votes
40 answers

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". What does this mean. OS: Fedora Core 8 Apache:…
bkulyk
  • 1,644
  • 2
  • 12
  • 17
52
votes
2 answers

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:
Lightness Races in Orbit
  • 358,771
  • 68
  • 593
  • 989
43
votes
1 answer

What is the difference between while(true) and for(;;) in PHP?

Is there any difference in PHP between while(true) and for(;;) besides syntax and readability?
Alastair
  • 1,480
  • 2
  • 16
  • 30
43
votes
2 answers

What's the Difference Between Extension and zend_extension in php.ini?

When I installed Xdebug through pecl, it added the following line to my php.ini file. extension="xdebug.so" and everything I used worked. Until today. Today I was having trouble setting up Xdebug for interactive debugging. I couldn't get anything…
Alan Storm
  • 157,413
  • 86
  • 367
  • 554
42
votes
5 answers

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 syntax error: Parse error: syntax error,…
Schwern
  • 127,817
  • 21
  • 150
  • 290
29
votes
0 answers

Pre-compiling PHP files

As a learning exercise, I'm trying to save the compiled state of a PHP file in order to execute it at a later time without having to go through zend_compile_file again. The first thing I did was write an extension that hooks zend_compile_file. If…
MyUsername112358
  • 1,157
  • 9
  • 33
29
votes
1 answer

Where's the php-src/PHP-Internals Main Entry Point

What function or bit of code serves as the main entry point for executing/interpreting a PHP program in the source of PHP itself? Based on things I've googled or read in books, I know that PHP is designed to work with a server of some kind (even…
Alan Storm
  • 157,413
  • 86
  • 367
  • 554
28
votes
1 answer

Why can't you inherit from a not-yet-defined class which inherits from a not-yet-defined class?

I research about class compilation, it's sequence, and logic. If I declare a class before a simple parent: class First extends Second{} class Second{} This will work OK. See live example across PHP versions. But if the parent class also has some…
sergio
  • 5,148
  • 6
  • 20
  • 44
27
votes
4 answers

Where can I learn about PHP internals?

What are good resources to start learning the internals of PHP and the Zend Engine?
Adam Ramadhan
  • 22,112
  • 25
  • 79
  • 120
26
votes
5 answers

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 detecting "reference to" and "reference from" given the…
borrible
  • 15,683
  • 7
  • 51
  • 69
26
votes
2 answers

In which order are objects destructed in PHP?

What is the exact order of object deconstruction? From testing, I have an idea: FIFO for the current scope. class test1 { public function __destruct() { echo "test1\n"; } } class test2 { public function __destruct() { …
bob-the-destroyer
  • 3,053
  • 2
  • 21
  • 29
25
votes
1 answer

Get PHP Opcodes Dynamically at Runtime

I want to build a PHP extension that can dynamically inspect every opcode generated from a PHP file and do some checking on that. I came across several websites and found out a couple of functions like zend_set_user_opcode_handler, but I fail to…
ebudi
  • 287
  • 2
  • 3
24
votes
5 answers

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 wondering what the performance of associative arrays…
Y Pgjn
22
votes
2 answers

Interchanging data with zend (multidimensional arrays)

I'm embeding PHP in my app (writen in Delphi 2010), using PHP4Delphi component to interface with php5ts.dll. I guess my program acts as extension for the PHP (sapi module?) as it registers some functions and constants which can be used in PHP…
ain
  • 21,481
  • 3
  • 47
  • 70
1
2 3
17 18