Wednesday, January 7, 2015

Developing PHP Extensions with C++ and PHP-CPP: Advanced

In my earlier articles, I have introduced the PHP-CPP lib to create an extension for PHP using C++ (first article and second article). In the latter, I demonstrated a bit of the OO side of writing a PHP extension with a Complex class doing complex number manipulations.



That introduction is not complete as the main focus of that article is more on the demonstration of the OO capability of PHP-CPP, not on the OO implementation details.


In this article, we will further drill down the Complex lib development, adding more member functions, and addressing some advanced topics in writing a PHP extension with OO features using PHP-CPP:



  • Returning this pointer;

  • Returning a Complex object pointer, i.e., a Complex *;

  • Exposing the __toString magic method;

  • Chaining member function calls;

  • Throwing an exception and handling it in PHP


Continue reading %Developing PHP Extensions with C++ and PHP-CPP: Advanced%




by Taylor Ren via SitePoint

No comments:

Post a Comment