Skip to main content

All Questions

Tagged with or
Filter by
Sorted by
Tagged with
15 votes
3 answers
2k views

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 ...
Alana Storm's user avatar
7 votes
3 answers
2k views

I'm loading XML files from disk using file_get_contents, and as a test I find I can load a 156K file using file_get_contents() 1,000 times in 3.99 seconds. I've subclassed the part that does the ...
halfer's user avatar
  • 20.2k
3 votes
1 answer
655 views

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'] ...
newmindcore's user avatar
4 votes
1 answer
653 views

I've been going through some PHP extension tutorials, but I can't find any information about how to overload existing function. For example, I want to change the fopen() to something like ...
Vasisualiy's user avatar
13 votes
2 answers
4k views

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 $...
ThinkingMonkey's user avatar
1 vote
1 answer
115 views

class a { public $test="msg1"; } $t1 = new a; echo "echo1: After Instantiation :<br/>"; xdebug_debug_zval('t1');echo "<br/><br/>"; $t2 = $t1; echo 'echo2: After ...
ThinkingMonkey's user avatar
17 votes
2 answers
489 views

Let's consider the following code: class a { public $var1; function disp(){ echo $this->var1; } } $obj1 = new a; echo '<br/>After instantiation into $obj1:&...
ThinkingMonkey's user avatar
3 votes
3 answers
2k views

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,...
ThinkingMonkey's user avatar
1 vote
1 answer
130 views

This is my setting: display_startup_errors = on display_errors = On error_reporting = E_ALL | E_STRICT //code1: $a = "abcd"; xdebug_debug_zval('a'); The above line of code would create a zval ...
ThinkingMonkey's user avatar
14 votes
2 answers
2k views

test.php as plain text: <?php $x = "a"; echo $x; test.php as opcode: debian:~ php -d vld.active=1 -d vld.execute=0 -f test.php Finding entry points Branch analysis from position: 0 Return found ...
Raffael's user avatar
  • 20.1k
11 votes
2 answers
3k views

How can I write PHP opcode, save it in a file and make the Zend Engine execute it? Any method or hack is welcome, as long as it does the trick.
Raffael's user avatar
  • 20.1k
0 votes
1 answer
78 views

I am trying to introduce few nifty cool concepts to the Zend Engine in a KDE environment. It's kinda "deep core" thing and requires lots and lots of veteran C coding and hacking around a moderately ...
Ashkan Kh. Nazary's user avatar
11 votes
1 answer
149 views

I am trying to build my own zend module (.so) We have multiple functionality that can be done in our own module which will improve our performance on a high traffic website (50k+ visits a day). ...
Erin Tucker's user avatar
  • 3,334
2 votes
1 answer
158 views

I'm trying to wrap a custom php extension from a C library, now I have an Initializer function which initiate a specific custom connection and seems to be expensive one and i should not run it each ...
Jau L's user avatar
  • 904
2 votes
2 answers
986 views

I need to add an entry to the superglobal $_SERVER-array within a PHP extension. I am quite sure that php_register_variable() will do the job, paasing key and value as arguments; but I have no idea ...
wonk0's user avatar
  • 14.1k
1 vote
1 answer
427 views

We have made a Zend extension which we want to write the addresses of the zval's echo is supposed to write out, but we cannot figure how to receive them because we have noticed that there is ...
Torben Pi Jensen's user avatar
0 votes
1 answer
495 views

Here is the php_ex.cc . When I compile my .so library the retur() method is not working. WHY? I have no errors, but It should print "test" and it doesn;t . need some help.THX [php_ex.cc] #include "...
sunset's user avatar
  • 1,413
1 vote
1 answer
2k views

I have in [example.cc] a method : std::string Car::accelerate (std::string n) { cout<<n<<endl; return n; } I would like to call this method from a php extension I wrote this in my [...
sunset's user avatar
  • 1,413
2 votes
2 answers
736 views

I am working in c++ under ubuntu. I have the following example: [car.h] #ifndef VEHICLES_CAR_H #define VEHICLES_CAR_H // A very simple car class class Car { public: Car(); void shift(int ...
sunset's user avatar
  • 1,413
1 vote
1 answer
148 views

There is something that confuses me. Let there be a class member Foo::$bar, which has to be initialized as an empty array in the constructor. If I do that (via zend_update_property), its refcount is ...
Flavius's user avatar
  • 13.8k
9 votes
0 answers
1k views

I am writing a PHP extension. From the C code I try to invoke a static method in PHP code. The PHP-method looks like this: <?php class Model { static method GetModelById($id) { ... } } ?> ...
Peter Schulz's user avatar
8 votes
3 answers
834 views

Ok maybe not so puzzling, but here it is. I was messing around and noticed this, typing just <?php in a file, just that, no space after that, nothing else just the tag, throws a parse error. ...
frostymarvelous's user avatar
52 votes
2 answers
3k views

It was noted in another question that wrapping the result of a PHP function call in parentheses can somehow convert the result into a fully-fledged expression, such that the following works: <?php ...
Lightness Races in Orbit's user avatar
1 vote
2 answers
261 views

When writing the syntax for an associative array in PHP we do the following $a = array('foo' => 'bar'); I am curious of the relationship of the => syntax, or possibly operator. Does this relate ...
grep's user avatar
  • 4,036
1 vote
1 answer
177 views

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's user avatar
  • 7,923
12 votes
1 answer
4k views

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?...
Alex's user avatar
  • 66.6k
5 votes
1 answer
630 views

When queries are made to mongodb, how does it's cursor deal with the result set in memory? Does the cursor retrieve all documents which match the query, at once? or does it retrieve 1 document at a ...
Jim Rubenstein's user avatar
10 votes
1 answer
6k views

How do the different MySQL Cursors within PHP manage memory? What I mean is, when I make a MySQL query that retrieves a large result set, and get the MySQL resource back, how much of the data that ...
Jim Rubenstein's user avatar
22 votes
2 answers
1k views

I'm embeding PHP in my app (writen in Delphi 2010), using PHP4Delphi component to interface with php5ts.dll. I guess my program acts as extension for the PHP (sapi module?) as it registers some ...
ain's user avatar
  • 22.8k
2 votes
1 answer
625 views

I am tweaking a zen-cart website to be more cpu efficient. After profiling it, I see that the getimagesize function is accounting for nearly 50% of page load time. The images are locally stored. One ...
user396404's user avatar
  • 2,819
4 votes
3 answers
536 views

<?php class A { public function instanceFunc() { echo "instance"; } public static function staticFunc() { echo "static"; } } A::instanceFunc(); // instance $a = new A(); $a->...
reeze's user avatar
  • 37
4 votes
3 answers
2k views

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, FILTER_VALIDATE_EMAIL); vs. http:/...
Alex's user avatar
  • 66.6k
16 votes
1 answer
16k views

how can i write my own module in C ? is it possible ?
Sourav's user avatar
  • 17.6k
1 vote
1 answer
1k views

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 /...
Alex's user avatar
  • 11
1 vote
1 answer
788 views

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: /...
user683831's user avatar
8 votes
3 answers
4k views

I created a PHP Hello World extension DLL with Microsoft Visual C++ 2008. I have the right php.ini (I know because when I enable and disable the gd2 extension, there is an effect), but when I load ...
Mark Lalor's user avatar
  • 7,943
1 vote
2 answers
327 views

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 ...
cjp's user avatar
  • 313
28 votes
5 answers
7k views

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 ...
borrible's user avatar
  • 17.5k
1 vote
2 answers
270 views

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 ...
StevenWang's user avatar
  • 3,886
3 votes
1 answer
833 views

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: ...
sassman's user avatar
  • 81
1 vote
1 answer
300 views

In my PHP extension, how can I create an op_array with no opcodes in it?
nc.'s user avatar
  • 7,339
32 votes
4 answers
7k views

What are good resources to start learning the internals of PHP and the Zend Engine?
Adam Ramadhan's user avatar
0 votes
1 answer
639 views

I'm about reading a tutorial about creating php extensions in C. I'm using Visual Studio 2008 and EasyPHP whose directory includes /ext folder (PHP extensions directory) this is the tutorial : http://...
SmootQ's user avatar
  • 2,122
2 votes
2 answers
559 views

1. static inline ulong zend_inline_hash_func(char *arKey, uint nKeyLength) 2. { 3. register ulong hash = 5381; 4. 5. /* variant with the hash unrolled eight times */ 6. ...
ajx's user avatar
  • 117
0 votes
4 answers
208 views

zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ss", &r1, &n, &r2, &m) What's "ss" for here?
pc2's user avatar
  • 3
5 votes
4 answers
765 views

if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|l", &flag) == FAILURE) { return; } Especially what's ZEND_NUM_ARGS() TSRMLS_CC doing?
ccr's user avatar
  • 81
3 votes
3 answers
2k views

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 ...
Unpossible's user avatar
  • 10.7k
6 votes
8 answers
3k views

Is it possible to see if two array variables point to the same memory location? (they are the same array)
Kirk Ouimet's user avatar
  • 28.6k
8 votes
6 answers
4k views

Hey there. Today I wrote a small benchmark script to compare performance of copying variables vs. creating references to them. I was expecting, that creating references to large arrays for example ...
fresskoma's user avatar
  • 25.9k
43 votes
6 answers
7k views

I'm pretty new to PHP, but I've been programming in similar languages for years. I was flummoxed by the following: class Foo { public $path = array( realpath(".") ); } It produced a ...
Schwern's user avatar
  • 167k