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 do I create an empty op_array?

In my PHP extension, how can I create an op_array with no opcodes in it?
nc.
  • 7,179
  • 5
  • 28
  • 38
1
vote
2 answers

Invoking a PHP function after all objects have been destroyed

I have seen several answers on object destruction order, and all point out that order is not guaranteed. Since I cannot control the order, I would like to invoke a function after all objects have been destroyed. register_shutdown_function is…
Stickley
  • 4,561
  • 3
  • 30
  • 29
1
vote
2 answers

Micro optimization on array keys

I have an array of which I am using some items to construct more arrays, a rough example follows. $rows = [ [1, 2, 3, 'a', 'b', 'c'], [4, 5, 6, 'd', 'e', 'f'], [4, 5, 6, 'g', 'h', 'i'], ]; $derivedData = []; foreach ($rows as $data)…
php_nub_qq
  • 15,199
  • 21
  • 74
  • 144
1
vote
3 answers

In PHP, when $foo = new Foo(), technically speaking, is $foo an object, or is $foo a reference?

Update: in http://php.net/manual/en/language.oop5.references.php it says: One of the key-points of PHP5 OOP that is often mentioned is that "objects are passed by references by default". This is not completely true. Why is that? The…
nonopolarity
  • 146,324
  • 131
  • 460
  • 740
1
vote
0 answers

PHP execition flow with interpretation and dynamic linking

This might be asked somewhere, but in total i couldn't read somewhere about the parsing/lexing/execution of PHP script, calling OS functions, loading linking libraries / modules, external files etc in brief. Let me explain : I read about the…
1
vote
0 answers

Zend HashTable API: zend_hash_clean()

I'm new to Zend engine and writing an extension. According to this page if I want to remove all elements from a hashtable but not actually destroy everything, then I can use the zend_hash_clean() function. However, when I carefully studied this…
J. Tam
  • 11
  • 1
1
vote
0 answers

Local variables in Zend module

I am writing a Zend module. I have implemented this 2 functions: PHP_RINIT_FUNCTION PHP_RSHUTDOWN_FUNCTION The first one in called when a request is made. The second is called for the response. I want to keep informations between the 2…
Bob5421
  • 7,757
  • 14
  • 81
  • 175
1
vote
0 answers

Finding from symbol_table is failing in php 7

I have couple of questions. I have written test case like this. $animals = array( array('Spook', 'spook.png'), array('Helmut', 'pic1.jpg') ); foreach($animals as $row){ $name = $row[0]; $picname = $row[1]; $picture =…
abhi7436
  • 43
  • 6
1
vote
1 answer

Cannot invoke another function within a PHP_FUNCTION() in C

I need to call a function within a PHP_FUNCTION() function in C to extend PHP, this is a multithread script and The function itself works perfectly using int main(). Here is what I try to achieve. #define NUM_THREADS 3 char…
user4672604
1
vote
2 answers

PHP internals - getting a boolean argument

While writing and looking at some PHP extension's source code I noticed that some use a LONG type flag to parse a boolean parameter: bool new_map_embed; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &new_map_embed) == FAILURE) { …
Shlomi Hassid
  • 6,500
  • 3
  • 27
  • 48
1
vote
1 answer

Create an opaque struct type using the LLVM OCaml API

I'm building a PHP compiler with an LLVM back-end. I will use the Zend type zend_string to represent strings. For this I need an LLVM pointer type called zend_string_ptr or whatever. How do I create this pointer type with the OCaml LLVM…
Olle Härstedt
  • 3,799
  • 1
  • 24
  • 57
1
vote
0 answers

How PHP allocate and free memory

For example. At the beginning of the script I created array which has size of 100M. After several operations I unset this array (refcount=0). So, I marked 100M of memory as free, but its still reserved by PHP. 1) Can other scripts which currently…
1
vote
1 answer

trying to understand php's zvals

I'm trying to understand PHP's zvals. So consider the following code:
1
vote
0 answers

How to declare anonymous function write in C for PHP extension?

I have the following code: class Demo { private $data = array(); public function foo($key, $value) { $this->data[$key] = function ($c) use ($value) { return $c + $value; }); } } As you can see the foo…
eaglewu
  • 458
  • 5
  • 12
1
vote
1 answer

Changing php.ini entries using zend API

I'm trying to change some options from php.ini using zend. I have my own empty extension, it works, uses global variables and initializes well, so everything seems fine... But i can't find an answer: Is it possible to change php.ini globals from…
Dmitry
  • 55
  • 8