Popular recipes tagged "php5"http://code.activestate.com/recipes/tags/php5/2013-02-10T00:40:26-08:00ActiveState Code Recipesphp backwards compatibility porting tips (PHP) 2013-02-10T00:40:26-08:00imam feriantohttp://code.activestate.com/recipes/users/633541/http://code.activestate.com/recipes/578452-php-backwards-compatibility-porting-tips/ <p style="color: grey"> PHP recipe 578452 by <a href="/recipes/users/633541/">imam ferianto</a> (<a href="/recipes/tags/backwards/">backwards</a>, <a href="/recipes/tags/compatibility/">compatibility</a>, <a href="/recipes/tags/old/">old</a>, <a href="/recipes/tags/php4/">php4</a>, <a href="/recipes/tags/php5/">php5</a>). </p> <p>Hello again, on december 2012, I was porting my old php code (php4) to new php 5.4.3. There are to many errors within code, especially for session, eregi, global variables and others. This some pieces step for compatibility porting:</p> <ol> <li><p>add global variable definiton on some function that need outside variable &lt;code&gt; function getuser(){ global $loginid,$password; } &lt;/code&gt;</p></li> <li><p>replace eregi(/find/,str) with preg_match(//,str)</p></li> <li><p>add function exists for function that not exists in php5.4.3. for example: &lt;code&gt; if(!function_exists("session_is_registered")){ function session_is_registered($var){ return isset($_SESSION[$var]); } } if(!function_exists("session_register")){ function session_register($var){ $_SESSION[$var]=$_GLOBALS[$var]; } } &lt;/code&gt;</p></li> </ol> <p>Ok there is my tips, how about you? </p>