Asked  7 Months ago    Answers:  5   Viewed   25 times

Is it possible to write some C or C++ code and compile to binaries, then use those binaries with php? Is it also possible to write a php library using C and C++ ?

If so, please tell how can I do so?



PHP is modular in design -- it consists of the "engine" and many extensions, some of which are essential (e.g. the "standard" extension) and some are optional. They can be compiled-in or loaded dynamically (via php.ini settings or the dl() function).

You can easily write your own PHP extension in C/C++, if you are willing to learn the API. Start with the documentation on how to "hack the Zend Engine".

Wednesday, March 31, 2021
answered 7 Months ago

You should point to your vendor/autoload.php at Settings | PHP | PHPUnit when using PHPUnit via Composer.

This blog post has all the details (with pictures) to successfully configure IDE for such scenario:

Related usability ticket:

P.S. The WI-18388 ticket is already fixed in v8.0

Wednesday, March 31, 2021
answered 7 Months ago

Yes, you could json_encode the variable you want to send back to client.

echo json_encode( array('variable' => 'your value' ) ); 

The client will receive the data through a callback when the request is completed. Without more clarification on specifics that's all i can offer, with some more details i can provide code samples depending on whether you're using a JavaScript library such as jQuery or doing a raw XHR request.

Edit: so in jquery to retrieve the variable above you would do the following.

$.getJSON('yourfile.php', function(data){
      console.log( data.variable ); 
Wednesday, March 31, 2021
answered 7 Months ago

On Mac OS X environment variables available in Terminal and for the normal applications can be different, check the related question for the solution how to make them similar.

Note that this solution will not work on Mountain Lion (10.8).

Saturday, May 29, 2021
answered 5 Months ago


array_column doesn't work with an array of objects. Use array_map instead:

$titles = array_map(function($e) {
    return is_object($e) ? $e->Title : $e['Title'];
}, $records);



The function now supports an array of objects as well as two-dimensional arrays. Only public properties are considered, and objects that make use of __get() for dynamic properties must also implement __isset().

See - Thanks to Bell for the hint!

Tuesday, June 22, 2021
answered 4 Months ago
Only authorized users can answer the question. Please sign in first, or register a free account.
Not the answer you're looking for? Browse other questions tagged :