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
4
votes
1 answer

Why does set_exception_handler(func) not catch exceptions?

An exception is thrown in my shutdown function and not caught within a try/catch block, for example:
Pacerier
  • 86,231
  • 106
  • 366
  • 634
4
votes
1 answer

callbacks in jni

Is there any way to pass a callback to java code, from C. And the call returns immediately. Later on, after completing the task, the java code can invoke that callback. I have a C extension for php that calls a java store to store some items in it.…
ata
  • 8,853
  • 8
  • 42
  • 68
4
votes
1 answer

How do I add an array as an Object Property to a class declared within a PHP extension?

I want my PHP extension to declare a class equivalent to the following PHP: class MyClass { public $MyMemberArray; __construct() { $this->MyMemberArray = array(); } } I'm following the examples in "Advanced PHP Programming"…
John Carter
  • 53,924
  • 26
  • 111
  • 144
4
votes
3 answers

PHP string length

PHP coding standards say: ... PHP holds the length property of each string, and that it shouldn't be calculated with strlen(). Write your functions in a such a way so that they'll take advantage of the length property, both for…
koubic
  • 597
  • 1
  • 11
  • 23
3
votes
1 answer

php extension: can not update class field using zend_hash_update

I want to realize this class into php extension: class MyClass { protected $attrs = array(); public function __construct($id = null) { $this->attrs['id'] = $id; $this->attrs['name'] = ''; } public function __get($key) { if…
newmindcore
  • 318
  • 3
  • 8
3
votes
3 answers

How does array_keys do the search for value?

How does PHP array_keys do the search for value? Example: $array2 = array("xyz", "xyz", "abc", "abc", "xyz", "xyz", "text", "abc", "text"); print_r(array_keys($array2,"abc")); Since they are key,value pairs. I am guessing PHP to do a search based…
ThinkingMonkey
  • 12,539
  • 13
  • 57
  • 81
3
votes
1 answer

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 :
gallien
  • 121
  • 1
  • 3
  • 11
3
votes
3 answers

How are PHP's built-in functions implemented internally?

are these functions written the same way as user functions? I mean with PHP code and with regular expressions and stuff like that? For example: filter_var($email,…
Alex
  • 66,732
  • 177
  • 439
  • 641
3
votes
2 answers

Which is faster between (string)$value and "$value" when casting to a string

In PHP, assuming $value = 12345;(an integer), which is faster when casting $value from an integer to a string; $value = (string)$value; or $value = "$value"; This is a kind of performance measure question and specifically for this case. Thanks for…
Derick Alangi
  • 1,080
  • 1
  • 11
  • 31
3
votes
1 answer

PHP Zend Engine Extension and static methods

On writing an extension for php (5.3) i want to access the zend_class_entry pointer on a static method. On non static methods i can use the getThis() macro and within Z_OBJCE_P macro like this: zend_class_entry ce* = Z_OBJCE_P(getThis()); Now the…
sassman
  • 81
  • 5
3
votes
3 answers

PHP String Length Without strlen()

Just browsing over the latest release of the PHP coding standards, and something caught my eye: http://svn.php.net/viewvc/php/php-src/trunk/CODING_STANDARDS?revision=296679&view=markup Coding standard #4 states that "When writing functions that deal…
Unpossible
  • 10,607
  • 22
  • 75
  • 113
3
votes
1 answer

Call object constructor (__construct) from a php extension

I'm just experimenting with a PHP extension and I would like to know what is the suggested/preferred way to call an object constructor within the extension. I've read that, by calling the object_init_ex function the constructor of that object is not…
3
votes
1 answer

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 provide information about the extension's version when…
Gordon
  • 312,688
  • 75
  • 539
  • 559
3
votes
4 answers

PHP: Why Does array Syntax on a Zero Length String Cast the String as an Array?

In PHP, you can use array syntax to access string indexes. The following program echos out H However, if you access the first character of a zero length string
Alana Storm
  • 164,128
  • 91
  • 395
  • 599
3
votes
1 answer

What does each pass of the PHP interpreter process?

I have an include file that defines a class then creates a global with an instantiation of that class as well as a function that returns the global (for access within other functions). Code-wise: class X { ... } global $x; $x = new…
bmacnaughton
  • 4,950
  • 3
  • 27
  • 36