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

265 questions
22
votes
4 answers

How does PHP memory actually work

I've always heard and searched for new php 'good writing practice', for example: It's better (for performance) to check if array key exists than search in array, but also it seems better for memory too: Assuming we have: $array = array ( 'one' …
George Garchagudashvili
  • 6,657
  • 12
  • 39
  • 53
21
votes
3 answers

Reading Zend Engine API code: What does ## (double hash) mean?

Out of curiousity, I'm reading the Zend Engine API code and encountered quite a number of ## in their #define's. For example, at /usr/lib/php5/Zend/zend_API.h: #define ZEND_FN(name) zif_##name #define ZEND_MN(name) zim_##name What does the ##…
Seh Hui Leong
  • 1,092
  • 8
  • 18
19
votes
4 answers

I am facing more memory consumption in Php 7 compare to PHP 5.6

When I was doing a benchmark, I found that PHP 7 was using more memory than PHP 5.6. So, I did a test. I ran a script containing only: $a=10; and below are the results for the memory used when I used PHP CLI without any modules (php -n) php 5.6 =…
developerCK
  • 4,162
  • 3
  • 14
  • 33
19
votes
7 answers

print_r() adds properties to DateTime objects

Consider the following code sample: $m_oDate = new DateTime('2013-06-12 15:54:25'); print_r($m_oDate); echo $m_oDate->date; Since PHP 5.3, this produces (something like) the following output: DateTime Object ( [date] => 2013-06-12 15:54:25 …
CHaP
  • 217
  • 2
  • 8
17
votes
2 answers

What is exactly happening when instantiating with 'new'?

Let's consider the following code: class a { public $var1; function disp(){ echo $this->var1; } } $obj1 = new a; echo '
After instantiation into $obj1:
'; xdebug_debug_zval('obj1'); $obj1->var1 =…
ThinkingMonkey
  • 12,011
  • 12
  • 51
  • 80
17
votes
1 answer

__memcpy_sse2_unaligned - what does this mean in detail?

While working on my compiler I got this error: Program received signal SIGSEGV, Segmentation fault. __memcpy_sse2_unaligned () at ../sysdeps/x86_64/multiarch/memcpy-sse2-unaligned.S:33 How do I get details of what went wrong here? I know from the…
Olle Härstedt
  • 3,348
  • 1
  • 18
  • 46
16
votes
1 answer

how to write PHP module in C

how can i write my own module in C ? is it possible ?
Sourav
  • 15,195
  • 32
  • 97
  • 152
15
votes
3 answers

Returning "Native" PHP Objects from an Extension

I'm dabbling with creating a PHP extension for a personal project. Beyond what's linked in the above article I have no knowledge of the zend_engine, and my C skills are 10 years out of date, and were only ever academic. All of which is to say "If…
Alan Storm
  • 157,413
  • 86
  • 367
  • 554
15
votes
2 answers
15
votes
2 answers

Do unused use statements decrease performance?

I want to know if unused use statements in my class affect performance of my php website? Does php include all classes in beginning or when need it? If second choice then I think it doesn't affect performance of my system. For Example: Use…
Farid Movsumov
  • 10,745
  • 8
  • 65
  • 92
15
votes
3 answers

Getting Started with PHP Extension-Development

Please suggest help articles or tutorials about PHP "low" level С-modules programming interface.
duganets
  • 1,783
  • 5
  • 19
  • 31
13
votes
2 answers

What is # next to object(someClass) in var_dump of an object? I have an inference. Am I right?

This is the code & its output I used to draw the inference below: class a { public $var1; public $var2; } $obj0 = new a; var_dump($obj0); class b { public $var1; public $var2; public $var3; } $obj1 = new b; …
ThinkingMonkey
  • 12,011
  • 12
  • 51
  • 80
13
votes
1 answer

Why is order of arguments in PHP's hash_equals() function important?

PHP 5.6 introduced hash_equals() function for safe comparison of password hashes and prevention of timing attacks. Its signature is: bool hash_equals(string $known_string, string $user_string) As described in the documentation, $known_string and…
Alex Shesterov
  • 21,630
  • 10
  • 65
  • 88
13
votes
1 answer

What is the difference between SplObjectStorage::contains and SplObjectStorage::offsetExists?

The PHP documentation is not very explicit and only states that: SplObjectStorage::offsetExists Checks whether an object exists in the storage. (PHP >= 5.3.0) SplObjectStorage::contains Checks if the storage contains the object provided. (PHP >=…
Tivie
  • 18,374
  • 5
  • 54
  • 77
12
votes
1 answer

How does PHP assign and free memory for variables?

I was wondering when does PHP free the memory which is used for a variables for example function foo(){ $foo = 'data'; return $foo; // <- is the memory space for `$foo` emptied at this point? } is it slower than: function foo(){ return…
Alex
  • 60,472
  • 154
  • 401
  • 592
1
2
3
17 18