Skip to main content

Questions tagged [php-internals]

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

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 ...
0 votes
0 answers
94 views

Adding new reference to any item in array affects behaviour of the array

I've seen many questions about this (one of them here) $a = array('a', 'b', 'c', 'd'); foreach ($a as &$v) { } foreach ($a as $v) { } print_r($a); and I get the answers, you shouldn't be ...
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 ...
0 votes
1 answer
58 views

in php programming where is the array data and the address being stored?

i am new to php . i want to know the place where the array data and the address of array are being stored ? are they storing in heap and stack , respectivelylike C# ? I read many articles but I could ...
2 votes
3 answers
3k views

Compiling a php extension into a dll

I've been attempting for a last few days to make use of the operator overloading extension (pecl.php.net/package/operator), which has apparently been updated recently to be compatible with 5.3 and 5.4....
0 votes
1 answer
425 views

Segfault Error when using zend_call_function()

i am trying to warp a C library around a PHP class using PHP's Zend Engine. The constructor function of the class is supposed to take a string and a function pointer. I was able to fetch strings ...
1 vote
0 answers
35 views

Are PHP zvals mutable?

I've been reading about memory management in PHP and learned that variables in PHP copy the reference to zvals as long as you don't do a write operation (copy on write paradigm). https://www....
46 votes
2 answers
22k views

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 ...
2 votes
2 answers
246 views

What's the behavior of count when array has more than 2147483647 elements?

On a 32-bit system, an array can have as much as 4294967295 elements (as per Artefacto's post on another thread). However, count returns the number of elements as an int, and on a 32-bit system, an ...
0 votes
0 answers
23 views

Is there an opcode in PHP VM that lets you stack allocate?

Title. Since you can enable escape analysis, there should also be an opcode that uses stack allocation instead of heap, right? Or how would that work?
0 votes
1 answer
191 views

Why the macro "ZVAL_COPY_VALUE(z,v)" seems to work unexpectedly in PHP Internal?

My question is about HashTable: The PHP VERSION debugged is PHP-7.0.12, I couldn't find out where the zval's str member is updated within the macro "ZVAL_COPY_VALUE(z, v)" when I add one new ...
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". ...
2 votes
1 answer
601 views

Make getimagesize() referenced cached values

I am tweaking a zen-cart website to be more cpu efficient. After profiling it, I see that the getimagesize function is accounting for nearly 50% of page load time. The images are locally stored. One ...
5 votes
4 answers
1k views

PHP Internals: How does TSRMLS_FETCH Work?

How does the PHP Internals TSRMLS_FETCH macro do its job? Per the PHP Manual While developing extensions, build errors that contain "tsrm_ls is undefined" or errors to that effect stem from the ...
4 votes
1 answer
266 views

Where is PHP echo implemented in the source?

You can lookup built-in functions by searching for e.g. PHPAPI(stream_copy_to_stream) and find the implementation in ext/standard/streamsfuncs.c. How to do that for a language construct like echo? I ...

15 30 50 per page
1
2 3 4 5
18