All Questions
Tagged with php-internals c
67
questions
2
votes
0
answers
174
views
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 ...
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 ...
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 ...
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
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 ...
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 ...
0
votes
1
answer
202
views
How to read this function in C?
While reading about PHP Zend Engine internals, I came across function
zend_parse_parameters() which is used as the following
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &number) ...
2
votes
2
answers
293
views
PHP7 hashtable internal structure
There is very efficient assoc. array C language implementation used in php source code.
/*
* HashTable Data Layout
* =====================
*
* +=============================+
* ...
2
votes
0
answers
207
views
What is the proper way to add elements to an empty array passed to an extension function in PHP 7.3?
I'm trying to port an old PHP extension of mine working for PHP 5.4 to PHP 7.3 (7.3.0 RC3 more precisely).
I'm building the extension using Visual Studio 2017 on Windows 10 Pro x64, building both for ...
29
votes
0
answers
1k
views
Pre-compiling PHP files [closed]
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 ...
7
votes
1
answer
878
views
Why `mysqli_query()` returns null? How can i figure it out?
Under certain circumstances, the built-in function in PHP called mysqli_query returns null. Such behaviour is not foreseen by the function's documentation that explains how to use it, so I tried to ...
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 ...
0
votes
1
answer
309
views
Try to write an internal function in the PHP extension, the results reported memory leak, looking for a long time did not find the reason
Recently, I read a book about PHP extensions and are ready to write a function, the function prototype is as follows:
array_groupBy(string $key, array $input, $forget = false):array
The function of ...
1
vote
0
answers
272
views
why does openssl_public_encrypt not accept even modulos for unpadded RSA?
Unpadded RSA is basically modular exponentiation. So it seems like openssl_public_encrypt($plaintext, $result, "$rsa", OPENSSL_NO_PADDING) ought to be a good way to do fast modular exponentiation (...
3
votes
1
answer
349
views
Expose version of extension in phpinfo() output
When writing custom extensions for PHP, you usually define a version string in the header file of your extension, e.g. something like
#define PHP_MYEXT_VERSION "0.1.0"
PHP will then use this to ...