Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

DZone.com:
Running JavaScript inside PHP code
Mar 01, 2012 @ 15:56:45

On DZone.com Giorgio Sironi has a new post about an interesting new PHP extension that lets you run javascript inside PHP - v8js (VERY alpha right now).

v8js is a new PHP extension able to run JavaScript code inside V8, Google's JavaScript interpreter that powers for example Chrome and NodeJS. This extension is highly alpha - and its API would probably change in the months ahead. Since documentation is lacking, I invite you to repeat the discovering process I follow in this post in case you find some differences in a new version of v8js.

He gives you the (PECL-based) commands to get the extension and it's needed dependencies installed and enabled. He uses PHP's own Reflection features to look at the extension and find its methods including: "executeString", "getPendingException" and "getExtensions". To show it in action, he implements an old standby to test new languages - the FizzBuzz example - in Javascript, executed inside the PHP. He also includes a quick example of how to load in an external Javascript file and execute the results.

tagged: javascript extension execute v8js google interpreter

Link:

Github.com:
Lisphp - Lisp in PHP
Jul 07, 2010 @ 15:55:55

From the "just because you can" category today Lunant has created a port of the Lisp language via an interpreter in PHP - Lisphp.

Lisphp is a Lisp dialect written in PHP. It was created to be embedded in web services or to be distributed within web applications. For that reason, it implements sandbox environment for security issues and multiple environment instances.

You can grab the latest code from the github page for the project as well as check out some of the tutorials and details about using the interpreter features like use/from, custom functions and custom macros.

tagged: lisp interpreter dialect github

Link:

Jack Diederich's Blog:
Comparing the Ruby/PHP/Python C Interpreters
Mar 17, 2010 @ 20:02:13

Recently on his blog Jack Diederich took a look at three different interpreters for Ruby, PHP and Python to see how they were implemented as compared to the language they're used in.

The other day I went poking around the Ruby and PHP interpreters (the current stable versions). I hadn't looked inside PHP since the 4.x series and Ruby I had never checked out. Like CPython the internals of both PHP and Ruby look something like their resulting language, but in C. For each interpreter I just compiled it and looked at how core types and extension types were implemented.

For PHP, he went with the PHP 5.2.13 release and talks about the compile process (a bit spammy), running the unit tests that come included and how the interpreter handles data types, core types and objects.

tagged: compare interpreter ruby python

Link:

Johan Mares' Blog:
Running PHP CLI shell scripts
Jan 06, 2009 @ 14:47:57

Johan Mares has a recent post about using PHP on the command line:

I already knew how to run PHP scripts from the command line (CLI), although I never really used it. What was new to me was that there are 2 ways of doing this. The first one is by using the php command and the second, and new for me, is by adding a shebang on the first line of your script.

His first way is to run the PHP file through the interpreter directly (via a command line call to something like "php myfile.php"). The second it to actually include the path to the interpreter inside the PHP file itself and use the shell to execute the contents based on that (adding something like "#!/path/to/php" at the top). Then you just make the file executable and you can run it like any other binary file.

tagged: cli commandline script method interpreter shebang

Link:

PHPImpact Blog:
PHP implemented in 100% Java
Aug 11, 2008 @ 12:58:31

In this recent post to the PHP::Impact blog, Federico talks about a slightly scary thing - a version of PHP implemented 100% in Java.

Quercus allows developers to incorporate Java code into PHP web applications and gives both Java and PHP developers a fast, safe, and powerful alternative to the standard PHP interpreter.

He mentions what it supports - things like Unicode and several of the popular extensions like APC, GD, MySQL, Oracle and PDF). There's also benefits he points out like the speed of the libraries (and safety) as well as interoperability with Java code and frameworks. Check out the official Quercus website for more information.

tagged: java implement quercus library interpreter benefit

Link:

DevShed:
Creating a Blog Application with Interpreter Classes with PHP 5
Apr 16, 2007 @ 16:53:00

DevShed has posted the final part of their look at working with the Interpreter pattern and its use in a PHP5 application with the creation of a simple blogging application.

As you can see, the logic that drives the interpreter pattern is rather easy to understand and implement with functional PHP code. Therefore, in this final installment of the series, I'm going to demonstrate how to get the most out of this handy pattern by developing a highly expansible blogging application. The application will be able to insert, update and delete blog entries, using a simple MySQL database as backend.

They start off with the creation of the MySQL class that will interface with the database backend for the application. Also included is a Result class to fetch the results from each query. On top of these, they create the Blog class to handle the requests for information and a BlogHandler class to push the submitted data back into the database.

Finally, they wrap it all together and give a real-life example of it in action, inserting new blog information and making an update of the content on one.

tagged: designpattern interpreter tutorial blog application designpattern interpreter tutorial blog application

Link:

DevShed:
Creating a Blog Application with Interpreter Classes with PHP 5
Apr 16, 2007 @ 16:53:00

DevShed has posted the final part of their look at working with the Interpreter pattern and its use in a PHP5 application with the creation of a simple blogging application.

As you can see, the logic that drives the interpreter pattern is rather easy to understand and implement with functional PHP code. Therefore, in this final installment of the series, I'm going to demonstrate how to get the most out of this handy pattern by developing a highly expansible blogging application. The application will be able to insert, update and delete blog entries, using a simple MySQL database as backend.

They start off with the creation of the MySQL class that will interface with the database backend for the application. Also included is a Result class to fetch the results from each query. On top of these, they create the Blog class to handle the requests for information and a BlogHandler class to push the submitted data back into the database.

Finally, they wrap it all together and give a real-life example of it in action, inserting new blog information and making an update of the content on one.

tagged: designpattern interpreter tutorial blog application designpattern interpreter tutorial blog application

Link:

DevShed:
Manipulating String Literals with Interpreter Classes in PHP 5
Apr 10, 2007 @ 14:08:00

DevShed has the second part of their look at the Interpreter design pattern series posted today. This time, they focus on the manipulation of string literals with Interpreter objects in a simple application.

Bearing in mind that in the first article of the series I illustrated how to use an interpreter class to handle a group of fictional users, in this tutorial I'm going to go teach you how to utilize this pattern for manipulating a set of string processing classes.

They start with a method (well, class really) of handling the strings themselves - a StringSaver class - that can write the information out to a file. On top of this, they create the Interpreter class, defining the different bits of functionality that can be performed on the string (uppercase, lowercase, etc). Finally, they combine the two in a simple example that applies the different interpretations to the given string.

tagged: tutorial string literal interpreter designpattern class php5 tutorial string literal interpreter designpattern class php5

Link:

DevShed:
Manipulating String Literals with Interpreter Classes in PHP 5
Apr 10, 2007 @ 14:08:00

DevShed has the second part of their look at the Interpreter design pattern series posted today. This time, they focus on the manipulation of string literals with Interpreter objects in a simple application.

Bearing in mind that in the first article of the series I illustrated how to use an interpreter class to handle a group of fictional users, in this tutorial I'm going to go teach you how to utilize this pattern for manipulating a set of string processing classes.

They start with a method (well, class really) of handling the strings themselves - a StringSaver class - that can write the information out to a file. On top of this, they create the Interpreter class, defining the different bits of functionality that can be performed on the string (uppercase, lowercase, etc). Finally, they combine the two in a simple example that applies the different interpretations to the given string.

tagged: tutorial string literal interpreter designpattern class php5 tutorial string literal interpreter designpattern class php5

Link:

DevShed:
Building Interpreter Classes with PHP 5
Apr 03, 2007 @ 15:32:00

DevShed is starting off another design pattern series with part one of their look at the interpreter pattern - commonly used along with the Composite pattern to create more modular applications.

In this series, which is comprised of three articles, I'll provide you with numerous code samples showing how to implement this useful pattern, ranging from building a simple application for managing user information to creating a decent blogger.

As mentioned, their goal is to create a simple blogging application (eventually), but for now they just need to lay the foundation. They start with an introduction to the pattern via the creation of the User and UserServer classes. Next up is the creation of the UserInterpreter class to handle the requests and pass them along to the UserSaver. Finally, they show it in use, saving inputted user information into an array.

tagged: designpattern interpreter class php5 tutorial basics designpattern interpreter class php5 tutorial basics

Link:


Trending Topics: