php-internals Questions

1

Solved

Would the PHP engine optimize the second example to pass the $arr by reference? function test1(array &$arr) { $arr[] = 123; echo $arr[0]; } function test2(array $arr) { echo $arr[0]; }
Apeak asked 16/12, 2015 at 17:43

3

I'm developing a PHP-extension, where an object method needs to return an array zval. The method looks like: ZEND_METHOD(myObject, myMethod) { zval **myArrayProperty; if (zend_hash_find(Z_OBJPR...
Boorman asked 24/7, 2013 at 20:39

1

Solved

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 ...
Bluish asked 11/9, 2015 at 14:38

1

Solved

I research about class compilation, it's sequence, and logic. If I declare a class before a simple parent: class First extends Second{} class Second{} This will work OK. See live example acro...
Pallua asked 14/4, 2015 at 13:42

1

Solved

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) ...
Vintner asked 12/1, 2015 at 22:8

1

Solved

Maybe this is weird question, but I can't work it out what happens internally in php when you write: use garcha\path\class; I'm not asking about purpose of namespaces, but about that statement i...
Confidant asked 4/9, 2014 at 19:46

4

Solved

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...
Lithography asked 1/8, 2014 at 13:27

5

Can someone explain how PHP implements associative arrays? What underlying data structure does PHP use? Does PHP hash the key and store it in some kind of hash map? I am curious because I was wonde...
Mindimindless asked 29/10, 2008 at 16:26

1

Solved

Is there any difference in PHP between while(true) and for(;;) besides syntax and readability?
Nethermost asked 7/4, 2014 at 14:53

6

Consider the code below: <?php $arr = array(); $arr['b'] = 'book'; foreach($arr as $key=>$val) { print "key=>$key\n"; if(!isset($arr['a'])) $arr['a'] = 'apple'; } ?> It is n...
Anoa asked 26/3, 2014 at 6:56

1

Solved

I often find references to the following quote being used when explaining that a PHP unset() doesn't trigger "garbage collection" immediately, but only when it sees fit (emphasis mine): ...
Cotter asked 27/11, 2013 at 0:14

2

Solved

When I installed Xdebug through pecl, it added the following line to my php.ini file. extension="xdebug.so" and everything I used worked. Until today. Today I was having trouble setting up Xdeb...
Heal asked 18/11, 2009 at 18:18

2

In a blog post "PHP Internals: When does foreach copy", NikiC stated that in a code like this: Snippet 1 $array = range(0, 100000); foreach ($array as $key => $value) { xdebug_debug_zva...
Luminary asked 11/8, 2013 at 14:51

1

NikiC stated in another thread: Right before [a foreach] iteration the $array is "soft copied" for use in foreach. This means that no actual copy is done, but only the refcount of the zval of ...
Haileyhailfellowwellmet asked 10/8, 2013 at 3:55

5

Solved

Is there a way in PHP to determine whether a given variable is a reference to another variable and / or referenced by another variable? I appreciate that it might not be possible to separate detect...
Countable asked 27/1, 2011 at 14:28

7

Solved

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 o...
Distal asked 12/6, 2013 at 12:53

1

Solved

When ref-assigning an array's element, the contents of the array are modified: $arr = array(100, 200); var_dump($arr); /* shows: array(2) { [0]=> int(100) // ← ← ← int(100) [1]=> int(200...
Hospitium asked 8/7, 2013 at 13:45

1

Solved

I've developed a PHP5 client extension for a server application i wrote, and so far it's working quite well, but it doesn't support persistent connections yet. Since this is something i want to imp...
Harebell asked 5/7, 2013 at 8:26

1

Solved

I'm developing a PHP extension, using C. So far I'm working on the proper validation of arguments, passed to the extension's function from PHP userspace. The macro ZEND_BEGIN_ARG_INFO_EX can be u...
Mclin asked 31/1, 2013 at 21:3

2

Solved

I wrote a PHP extension to access functions in a static lib, I built PHP as a CGI, and everything seemed to work (after days of working on it..) Thrilled once everything worked, I re-compiled PHP ...
Hillman asked 2/1, 2013 at 15:36

1

Solved

I am trying to write an extension for php5.4 which basically wraps a very simple class in CPP. This is for education purposes. I find the way to do it in php5.4 has changed from php5.3 Where d...
Gide asked 31/12, 2012 at 19:47

1

Solved

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...
Stannwood asked 16/8, 2012 at 8:8

1

Solved

i'm writing a php extension for my c++ library which is defined something like this: bool getPids(map<string,string> pidsMap, vector<string> ids); now, i'm writing a php wrapper for ...
Streamline asked 6/8, 2012 at 18:49

4

Solved

What are good resources to start learning the internals of PHP and the Zend Engine?
Linton asked 8/12, 2010 at 16:23

3

Solved

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 we...
Redness asked 19/3, 2012 at 16:31

© 2022 - 2024 — McMap. All rights reserved.