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
1
vote
1 answer

How does PHP implements its all fit container `array`?

If it were c++,this can be achieved by template,but as we know PHP is written in c,how's this kind of data struct implemented without template?
cpuer
  • 7,413
  • 14
  • 35
  • 39
1
vote
1 answer

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 amongst totally unrelated definitions (with the…
i336_
  • 1,813
  • 1
  • 20
  • 41
1
vote
1 answer

Linking a php module with a .so library on linux

I am working on a PHP module and I am having trouble linking with shared libraries under Linux. What is the command I need to put in my config.m4 to link against a .so? If I have my .so file under /usr/lib/ or /usr/lib64/ the compiler should be able…
Alex
  • 11
  • 2
1
vote
0 answers

What is the role of uninitialized_zval in the PHP kernel?

uninitialized_zval appears in multiple places in the PHP kernel, but I don't know what it does. For example, in the ZEND_ASSIGN_DIM_SPEC_CV_UNUSED_OP_DATA_CONST_HANDLER handler: variable_ptr =…
1
vote
1 answer

What goes in the PHP root buffer and what happens if it gets bigger than 10K

I have a long-running PHP script that seems to have a memory leak and that got me diving into how PHP garbage collection works. I had some questions about it and maybe there are some people on here who know enough about the innards to answer…
rbalik
  • 93
  • 5
1
vote
1 answer

try to embed my C code in PHP script

I am learning how to use SWIG, and I am writing a php wrapper for a C library. The extension successfully compiles, but when I try to call the function I get this error: php: symbol lookup error: /usr/lib/php5/20090626+lfs/fact.so: undefined…
user683831
  • 51
  • 3
1
vote
2 answers

Fetch the function return value in PHP extension C++

I have created an php extension in c++ which tracks the call graph of each request(centos7-64 bit,PHP5.6).And now,I want to get the function return value of each function. It can be done by using zend_excute_data structure(original_return_value). …
Durai
  • 87
  • 12
1
vote
0 answers

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 x64 and x86 architectures. The extension provides…
1
vote
1 answer

File write not working in PHP extension c/c++ (linux)

I have created my own PHP extension in c++ (linux). when zend engine compiles the PHP code am getting the active user functions and internal functions name. To debug this php extension am using zend_printf to print the values. Instead of…
Durai
  • 87
  • 12
1
vote
1 answer

Why does var_dump(debug_backtrace()) within a method triggers object's __debugInfo()?

Could someone explain me why in the following case: class A { public function methodA() { var_dump(debug_backtrace()); } public function __debugInfo() { return []; } public function __clone() { echo…
tonix
  • 6,671
  • 13
  • 75
  • 136
1
vote
2 answers

How can I make/patch php source (c code) to read an array from php.ini?

I'm experienced with php but I'm a novice to the php source and php extensions. I want to extend php so that it randomly chooses an upload_tmp_dir from an array, rather than one fixed dir. It doesn't look like php and the ini-file reading code has…
cjp
  • 313
  • 1
  • 8
1
vote
0 answers

Explanation on year format behaviour for PHP DateTime

Using ISO 8601 to manage date and time formats I'm in trouble dealing with "year only" dates. Example : new DateTime(2013); give me: DateTime Object ( [date] => 2017-11-27 20:13:00.000000 [timezone_type] => 3 [timezone] =>…
Nico
  • 439
  • 3
  • 16
1
vote
2 answers

Php extension problems

I get a tricky problem when i am trying to create a php extension with c, with an array returned. I do as some tutorials said, but i need to return an array. array_init(return_array) in all examples is said to initialize an returning-array, but i…
StevenWang
  • 3,625
  • 4
  • 30
  • 40
1
vote
1 answer

How to get a function name when I hooked it in a php extension

I tried to write a PHP module which is used to detect zend internal function which is called in a php cgi file. Liked code shown below,I want get its name -- 'printf' in my code. Now I hooked this function with a…
Solomon
  • 21
  • 2
1
vote
0 answers

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 (where $rsa contained the modulus and the exponent…
neubert
  • 15,947
  • 24
  • 120
  • 212