POT
POT
POT
Main menu

Download

Forum

SVN

Prev Next

PHP 5.0

Some things that you should know if you use POT under PHP 5.0.x.

Table of Contents

PHP 5.0

PHP5 was a huge step in PHP histroy. It is completly other language then PHP4 (and older versions). POT is written for PHP5 but currently most PHP5 installations are done with PHP 5.1 and higher versions. PHP 5.0 differs from next versions in few details (or even not details, but huge changes, but those mostly doesn't affect POT). There are some important things you should know if you use POT with PHP 5.0.

PDO

POT requires PDO extension. It is bundled with PHP since 5.1 version. If you use PHP 5.0 you still can install PDO, but you need to do that using PECL extensions. Detailed information about how to do that are in PHP manual PDO page.


Sub package "compat"

If you use PHP 5.0 you should include special compatibility assurance library. POT uses some mechanisms that exists since PHP 5.1 like Countable interface. It doesn't disallow you using POT with PHP 5.0. Compatibility library will create unexisting interfaces, classes, functions, constants etc. However keep in mind that you won't be able to use PHP 5.1 and newer language mechanisms as it is not possible to redefine PHP behaviour. Here is an example:

  1. <?php
  2.  
  3. // do that before any POT operations!
  4. include('compat.php');
  5.  
  6. // to not repeat all that stuff
  7. include('examples/quickstart.php');
  8.  
  9. // STEP 1: no error here - even thought we loaded class that implements Countable interface which does not exists in PHP 5.0 SPL library, because 'compat' library defines it.
  10. $list new OTS_Players_List();
  11.  
  12. // STEP 2: we can do that in every version - count() is in fact just a public method
  13. echo $list->count();
  14.  
  15. // STEP 3: it won't work correctly in PHP 5.0 - PHP won't call internaly count() method of object, will print trivial count() evaluation result on object
  16. echo count($list);
  17.  
  18. ?>

It is important to note that you have to load compat.php library before loading POT toolkit itself. This library by itself is not connected with POT in any way and you can freely separate it.

Nothin new

Compatibility library makes you sure, that POT scripts won't cause FATAL errors if you run them on older versions of PHP. However it doesn't introduce any new mechanisms so you won't find anything new in this package. It is safe to include compat.php file even if you work with PHP version 5.1 or newer, but there is no point in doing that.


__autoload()

POT registers own __autoload() handler with spl_autoload_register(). This function exists since PHP 5.1.2. Compatibility library defines this function as definer of another function - ordinary __autoload(). If you have own __autoload() function, compat's spl_autoload_register() won't redefine __autoload() to avoid E_ERROR. You then need to bind POT::loadClass() method to your __autoload() function manualy.



What about older PHP versions?

No way. POT was written using new PHP5 object engine - you cant use it with PHP4 and older versions of PHP, PHP/FI.

Prev Up Next
Basics POT Database