This class encapsulates an embedded PHP5 intepreter. It provides proxy methods (via AUTOLOAD) to all the functions declared in the PHP interpreter, transparent conversion of Perl datatypes to PHP (and vice-versa), and the ability for PHP to similarly call Perl subroutines and access the Perl symbol table.

The goal of this package is to construct a transaparent bridge for running PHP code and Perl code side-by-side.

Instantiates a PHP::Interpreter object, and creates an associated PHP interpreter instance. An anonymous hash of initial values may be passed. The supported initial value keys are:

GET

An array ref that will be installed in the PHP $_GET autoglobal array.

POST

An array ref that will be installed in the PHP $_POST autoglobal array.

COOKIE

An array ref that will be installed in the PHP $_COOKIE autoglobal array.

SERVER

An array ref that will be installed in the PHP $_SERVER autoglobal array.

ENV

An array ref that will be installed in the PHP $_ENV autoglobal array.

FILES

An array ref that will be installed in the PHP $_FILES autoglobal array.

OUTPUT

Change the output handler. By default, any data sent to STDOUT in PHP will be redirected to STDOUT in Perl. If OUTPUT is a scalar reference, then instead output will be appended to that scalar reference. If OUTPUT is a coderef, then whenever PHP emits data, that coderef will be called with the output fragment as its argument.

INCLUDE_PATH

A string that overides PHP's include_path ini setting.

Any other data that is passed will be installed in the PHP global symbol table. So for instance if you set:

$php = PHP::Interpreter( BRIC => { element => $e, session => $s } );

Then PHP will create the globally scoped $BRIC array with the keys 'element' and 'session', pointing at the appropriately converted or wrapped Perl variables $e and $s.

if($php->is_multithread) {
# I can instantiate a second independent interpreter
}

A runtime check to determine if PHP is thread-safe - i.e. if more than one interpreter can be simultaneously instantiated. If not, further calls to PHP::Interpreter->new() will return the original PHP interpreter instance.

Calls the PHP function specified by the first argument, passing the remaining arguments as parameters. Returns the converted return value of the function back into Perl. Throws an exception if an error is encountered.

In general, the PHP::Interpreter module attempts to make type conversion between Perl and PHP completely transparent. For non-tied, non-magical, and non-objects, this works well. However, when passing these special types, some considerations must be taken into account.

The PerlSV class is the base PHP wrapper class that serves as an opaque container for Perl objects in PHP. It proxies all method calls and attribute accesses. This class uses call and attribute accessor overloading to provide access to the object.