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

269 questions
2
votes
2 answers

Which PHP function uses such hash algorithm?

1. static inline ulong zend_inline_hash_func(char *arKey, uint nKeyLength) 2. { 3. register ulong hash = 5381; 4. 5. /* variant with the hash unrolled eight times */ 6. for (; nKeyLength >= 8; nKeyLength -= 8) { 7.…
ajx
  • 117
  • 1
  • 4
2
votes
2 answers

Implicit void return in PHP 7.1?

I found in here the new spec: https://wiki.php.net/rfc/void_return_type function lacks_return(): void { // valid } function returns_nothing(): void { return; // valid } function returns_void(): void { return void; // valid } Ask: Do you…
prosti
  • 42,291
  • 14
  • 186
  • 151
2
votes
1 answer

Using custom PHP module, why isn't $_POST being populated?

I have compiled PHP 5.6.27 on macOS 10.12.1 Sierra as a static library (no small feat in and of itself). I have linked my app to all required libraries and it is building without error. Using the static PHP library, I am able to both execute…
Jon
  • 1,469
  • 1
  • 14
  • 23
2
votes
1 answer

How to upgrade PHP function parameters work with new Zend API?

I am working on a php extension to upgrade it to PHP7, my question is about INTERNAL_FUNCTION_PARAMETERS. In the previous version it is defined as: INTERNAL_FUNCTION_PARAMETERS int ht, zval *return_value, zval **return_value_ptr, zval *this_ptr,…
Genjutsu
  • 223
  • 2
  • 12
2
votes
1 answer

Fetching zend resource without knowing type of the resource

It is possible to fetch the zend resources (zend_fetch_resource) without knowing the type of the fetching resource? If so, how? Note: I am writing PHP extension.
innocenat
  • 574
  • 7
  • 21
2
votes
1 answer

How much memory does a variable with int value require in PHP?

I know, this question might have been asked a few times before, but I've read all the similar question here and all the answers and still don't understand. So, I have a single variable declaration in my script: $a = 255; How much memory will this…
Alexander Guz
  • 1,334
  • 12
  • 31
2
votes
1 answer

PHP-FPM pool status of process last-request-cpu

I have installed a PHP and enable the FPM function, but i feel uncertain about the FPM status data(like the process last-request-cpu), below is my php-fpm.conf detail. [www] ; Unix user/group of processes user = www-data group = www-data ; Chdir…
Terry
  • 51
  • 5
2
votes
3 answers

What algorithm does array_sum use in PHP?

what algorithm does array sum uses to make it much faster than some looping through? Is it prefix sum / suffix sum or something else?
Ajeet Singh
  • 417
  • 7
  • 23
2
votes
0 answers

How does foreach work?

I have an issue which I can't explain for now. It's well-known that foreach in PHP works with copy of array, i.e. it copies the array first and then iterates through it. All fine and dandy. But this is weird: $array = ['foo' => 1]; foreach($array as…
Alma Do
  • 37,009
  • 9
  • 76
  • 105
2
votes
1 answer

how to call a php extension method from another php extension method

I write a php extension which contains a simple method, and it works well. I want to call "mysql_connect" method in this method. I have tried to find some documents or some guides ,but failed. My extension method code is…
user3255814
  • 243
  • 2
  • 5
2
votes
2 answers

Similar syntax causes strange, repeated compile errors when building PHP from source on Windows

I am trying to build PHP from source per these instructions. The configure works really well, but when I get to the nmake part, things fall apart. I have no idea why I am getting errors about struct's, the lines referenced are functions! I have put…
Alec Gorge
  • 17,110
  • 10
  • 59
  • 71
2
votes
2 answers

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 int is at most 2147483647. What will count return…
Pacerier
  • 86,231
  • 106
  • 366
  • 634
2
votes
1 answer

Why does missing "require" / "include" call error_handler an extra time?

I have a custom error handler set up using set_error_handler. When I tried to include a file that doesn't exist, PHP calls error_handler one more time than it should:
Pacerier
  • 86,231
  • 106
  • 366
  • 634
2
votes
1 answer

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(200) } */ $r = &$arr[0]; var_dump($arr); /*…
Pacerier
  • 86,231
  • 106
  • 366
  • 634
2
votes
3 answers

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. I've tried compiling it in windows (64-bit…