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
0 answers

How to call a PHP function from zend_compile.c?

I can't figure out how to call an existing PHP function, everytime I end up either with a segmentation fault or a Fatal error. Disclaimer: I'm not experienced at all in low level programming, just learning and trying things. I tried different ways,…
Bloops
  • 744
  • 1
  • 11
  • 15
2
votes
0 answers

how to allocate & deallocate memory in php?

I'm trying to allocate memory dynamically in my code and release them ,I tried to use zend_mm but I couldn't add it to php 7,I'm using php 7.4 and xampp server , if it is impossible please tell my the Alternatives to do that. the problem is ,I try…
M.sharf
  • 21
  • 3
2
votes
3 answers

How come usort (php) works even when not returning integers?

Yesterday at work I stumbled upon a piece of code that was roughly like this: uasort($array, function($a, $b) { return isset($a['sort_code']) && isset($b['sort_code']) && $a['sort_code'] > $b['sort_code']; }); this flipped a couple of switches…
tomtom
  • 21
  • 4
2
votes
1 answer

Does mysqli_close() do anything other than just destroying the object?

I know that using mysqli_close() is not needed, because PHP will destruct the object when the script is finished. What I would like to know is why do we have such a function in the language in the first place? Does it do anything else, other than…
Dharman
  • 30,962
  • 25
  • 85
  • 135
2
votes
1 answer

pdo_module.obj : error LNK2019: unresolved external symbol "int __cdecl php_pdo_register_driver(struct pdo_driver_t *)"

LINK: unresolved external symbol :php_pdo_register_driver I'm writing a PHP PDO ext demo with PHP7.2.21, when I tried to register my ext on PDO, I got an error. PHP_MINIT_FUNCTION(pdo_my_mysql) { #ifdef _PDO_CDATA_TRACE_ PRINT("invoke…
Deric Lee
  • 81
  • 3
2
votes
1 answer

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 option is to go through zen-cart's source code and…
user396404
  • 2,759
  • 7
  • 31
  • 42
2
votes
1 answer

Getting function argument value from PHP extension in c++

I have created php extension in c++.In version php 5.6 can able to get currently executed function details. I was getting the arguments value as follows, if (real_execute_data->function_state.arguments) { void **p =…
Durai
  • 87
  • 12
2
votes
0 answers

The Zend Engine API version 320170718 which is installed, is newer

I am currently experiencing a problem with xdebug. I wanted to do a php bin/console cache:clear for my Symfony application but it got me this error: Warning: Xdebug MUST be loaded as a Zend extension in Unknown on line 0 So I installed the…
Lucatorze
  • 107
  • 1
  • 9
2
votes
2 answers

PHP7 hashtable internal structure

There is very efficient assoc. array C language implementation used in php source code. /* * HashTable Data Layout * ===================== * * +=============================+ * | HT_HASH(ht, ht->nTableMask) | * …
legale
  • 612
  • 7
  • 9
2
votes
0 answers

Apache, mod_php, and MINIT

When running PHP programs using mod_php, when does PHP call its extension's MINIT functions? Does this happen When the apache web server restarts? Whenever apache spins up a new thread pool to handle PHP requests? Whenever apache spins up a new…
Alana Storm
  • 164,128
  • 91
  • 395
  • 599
2
votes
1 answer

PHP Internals: Where are Arrays Created

What code in the php-src repo handles a PHP programmer creating an array? That is -- as a PHP programmer I might do something like this $foo = array(); $foo = []; Behind the scenes, I assume there's some bit of central PHP internals code that's…
Alana Storm
  • 164,128
  • 91
  • 395
  • 599
2
votes
1 answer

How to get a function args when I hooked it in a php7.0 exetension

I tried to write a php extension to get function args. In this example is 'ls'. I hooked this function with zend_set_user_opcode_handler, and the function codes are. PHP_MINIT_FUNCTION(hello) { …
mashiro
  • 41
  • 3
2
votes
1 answer

PHP Internals: Difference Between INI Macros

I'm working in a C codebase for a PHP extension. This extension defines several php.ini settings. From what I've seen, there are two macros that do this. They are PHP_INI_ENTRY_EX and STD_PHP_INI_ENTRY_EX. PHP_INI_BEGIN() PHP_INI_ENTRY_EX…
Alana Storm
  • 164,128
  • 91
  • 395
  • 599
2
votes
1 answer

Confusion using xdebug_debug_zval between refcount and is_ref

I'm using xdebug_debug_zval in order to understand how references changed between PHP 5 and PHP 7. '; foreach ($array as &$ref)…
Nico
  • 439
  • 3
  • 16
2
votes
2 answers

Missing symbol after compiling swig interface

Im trying to compile a php interface for my linux shared object and i have managed to get it to compile all right using the output from swig, however when i try and load the so it complains of a missing symbol: error: undefined symbol:…
Lodle
  • 31,277
  • 19
  • 64
  • 91