如何讓PHP5 Class 能在PHP4執行

執行後回傳錯誤訊息


Parse error: parse error, expecting `T_OLD_FUNCTION’ or
`T_FUNCTION’ or `T_VAR’ or `’}” in ….

所以助益下列4個步驟

  1. 刪除所有 PUBLIC, PRIVATE and
    PROTECTED 關鍵字
  2. Prefix “var” keyword before each variable declared in the
    class.
  3. Rename the constructor of the class (of any) from __construct() to
    NameOfTheClass()
  4. Look for PHP 5 specific functions like simplexml_load_string()
    and replace/recode them with PHP4 equivalent code.
以下為修改範例

In PHP 5

class  dummy() {

private $variable;

public function __constructor(){

//Contructor function....

}

public function getValue() {

..........

In PHP4

class  dummy() {

var $variable;

function dummy(){

//Contructor function....

}

function getValue() {

..........


Powered by ScribeFire.

沒有留言:

張貼留言