Section 1: Installing and Loading XPHP

Software Requirements

The XPHP class requires the SimpleXML extension compiled into PHP. It is included and enabled in PHP by default, starting with version 5.0.
Support for APC and XSL is built into XPHP, but neither is required.

Loading XPHP

To begin using XPHP, you must include or require the class in your PHP script:

require '/path/to/class.xphp.php';

You must then create an instance of the XPHP class, with the following line:

$xphp=new XPHP();

This is all that is required to process a web page containing XPHP tags. Note that by default XPHP will start an output buffer to be processed at the end of script execution. If you wish to disable the output buffer and use XPHP in a manual mode, pass "false" to the XPHP tag when it is created. You can then process strings and files manually:

$xphp=new XPHP(false); // init XPHP with output buffer disabled
echo $xphp->parseString('a string containing an XPHP tag'); // manually parse a string
echo $xphp->parseFile('/path/to/remote/file'); // or, manually parse a file
	

Note: The manual mode of XPHP will be revisited later, but this guide will continue with the assumption that you are running XPHP normally, with an output buffer.

Autoloading XPHP

The recommended way to load XPHP is to simply instantiate the class and let the __autoload() function require the XPHP class file automatically:

function __autoload($class) { // autoloads class files
switch($class) {
	case 'XPHP': // intercepts the first instance of XPHP
	    require '/path/to/class.xphp.php';
	    break;
};
};
	

« Introduction | Section 2 of 6: Simple Usages »