Source for file compat.php
Documentation is available at compat.php
* Compatability with various different PHP versions
* PHP5 changes the way the world revolves... well, it changes the way
* objects are handled so that $object is always a reference to an
* object. The consequence is that in PHP5, this:
* in PHP4. In PHP5, the = operator is copy by reference not copy by value.
* Conveniently, PHP5 provides you with the clone keyword to get around this.
* Inconveniently, that same keyword is not in PHP4 so you can't just
* use it to get around your problems.
* If the version of PHP being used here is earlier than 5.0, then use
* a PHP-only inplementation of the clone keyword (as a function) from the
* PEAR PHP_Compat library:
* http://pear.php.net/package/PHP_Compat
* So now, instead of using the above construct to copy the $object, you
* $copy = clone($object);
* Note that in normal PHP5, you would not include the parentheses as clone is
* a keyword not a function, but for the PHP4 compatability to work, it has to be
* written as a function. PHP5 will just throw away the parentheses, pretending
* that they are for (an unneeded) grouping not a function call.
* @author Stuart Prescott
* @copyright Copyright Stuart Prescott
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
/** Load ancillary functions */
require_once 'inc/typeinfo.php';
/** php-compat implementation of clone for PHP4 */
#include_once 'PHP/Compat/Function/clone.php';
// Needs to be wrapped in eval as clone is a keyword in PHP5
function clone($object) {
if (!is_object($object)) {
user_error(\'clone() __clone method called on non-object\', E_USER_WARNING);
// Use serialize/unserialize trick to deep copy the object
#this results in a memory leak under PHP4.4.2
#$object = unserialize(serialize($object));
// If there is a __clone method call it on the "new" class
if (method_exists($object, \'__clone\')) {
function type_is_a($a, $b) {
function date_default_timezone_set($tz) {
// PHP5 complains if you use the is_a construct, so may this function across to
// instanceof. Note that this is not exactly the same as instanceof will throw
// errors in places where is_a didn't.
function type_is_a($a, $b) {
Documentation generated on Tue, 06 Mar 2007 10:01:05 +0000 by phpDocumentor 1.3.0