Skip to main content

Questions tagged [php-internals]

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

php-internals
1 vote
1 answer
507 views

How can I overwrite an internal Zend function with a PHP extension?

Hope this isn't too silly a question to ask. I'm fairly new to C and PHP internals but looking to learn more about them. I've recently began looking into development of PHP extensions. I'm trying to ...
fufyayokku's user avatar
0 votes
1 answer
77 views

Passing HashTable data from php.ini to an extension method: corrupted values

I am trying to make a PHP (7.4) extension use in an extension method a setting from php.ini (like myext.map=key1=val1,key2=val2;) parsed as an associative array. I want the parsing to happen in ...
Alexander Mashin's user avatar
0 votes
1 answer
92 views

Are `zval *retval` argument and the `zval *` return value of the `zend_call_method` the same?

Is the zval * value returned by the zend api method zend_call_method same as the zval *retval argument passed into it? I can see that zend_call_method is declared in zend_interfaces.h. I tried ...
Joyce Babu's user avatar
  • 20.3k
4 votes
1 answer
700 views

Why does php allow invalid return type declerations it knows it can't allow?

As far as I can tell php has the ability to prevent a return type from being declared where it knows it's problematic. class Foo { public function __clone(): Baz { return new Baz; } } ...
emptyheap's user avatar
4 votes
1 answer
930 views

Where is the source code for strlen() function in PHP?

I was looking through php-src/Zend/zend_API.c and couldn't find the source code for the strlen() function in PHP anywhere. Grepping through the code base didn't really help as it's littered with libc ...
emptyheap's user avatar
2 votes
3 answers
2k views

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['...
tomtom's user avatar
  • 21
8 votes
3 answers
432 views

Duplicate array keys (Notice: member variable "a" returned from __sleep() multiple times)

The title may seem a bit silly but I'm totally serious with this. Today at work I came across a weird PHP behaviour which I could not explain. Luckily this behaviour is fixed in PHP 7.4, so it seems ...
Benjamin Paap's user avatar
2 votes
1 answer
226 views

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 ...
Dharman's user avatar
  • 32.6k
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 ...
AKJ's user avatar
  • 1,018
1 vote
1 answer
277 views

What is causing this strange memory corruption in my test PHP extension?

I recently needed a list of compiled-in signal names so I could print nice messages like "Interrupted by SIGINT (2)". get_defined_constants() is unusable for this as it jumbles SIGINT, SIGTRAP etc in ...
i336_'s user avatar
  • 1,961
2 votes
1 answer
540 views

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) { #...
Deric Lee's user avatar
0 votes
1 answer
162 views

Is there a way in php to count the nested stucture level?

I'm experimenting with a way to more easily debug Cronjob Scripts with PHP. without having xdebug etc. accessible on the server. For this, I'd like to get the number of nested structures the code ...
Philipp's user avatar
  • 137
0 votes
0 answers
52 views

PHP API Reflection

I want to find where such messages are generated at a low level. Uncaught TypeError: Argument 1 passed to A::__construct() must be an instance of B I downloaded the source PHP 7. And tried to find ...
Eugene Kapelko's user avatar
11 votes
2 answers
1k views

Why is in_array strict mode on integers slower than non-strict mode?

I always thought that in_array strict mode will be faster or at least the same speed as non-strict mode. But after some benchmarks I noticed there is a huge difference in execution time between them ...
Tom's user avatar
  • 379
4 votes
1 answer
371 views

Why increasing refcount of zval not working?

I'm dumping a zval container running on PHP version 7.3.5 (opcache is activated and PHP is thread safe enabled) following this given code : <?php $a = "new string"; $b = $a; xdebug_debug_zval( '...
gallien's user avatar
  • 131

15 30 50 per page
1
2
3 4 5
18