Tuesday, July 30, 2013

Can't Run AMFPHP In PHP 5.3.8 It's So easy to RUN Dude...

I tried the AMFPHP environment PHP 5.3.0
http://localhost/amfphp/browser/
I got a message .....  That's Really Weird !!
Function eregi_replace () is deprecated .
C: \ xampp \ htdocs\ amfphp \ core \ shared \ util \ MethodTable.php on line 505
Error retrieving service info:

Now,
 I can do two things about this small problem :
  1. Change the settings in your php.ini file to disable the deprecated warnings.
  2. Replace the php code in that specific amfphp core file, using the new equivalent function.

Personally I suggest you do the second if 1st one works. 

Why are we waiting for.....? Go -- :)

  •   Change the php.ini file




Locate the php.ini file, you will normally find the php.ini file in the bin directory of your webserver.
This will open the php.ini file in your text editor.
Now search (you might want to use the search function) for “error_reporting =”.
This will be set to the default value which is “error_reporting = E_ALL”.

Changing this to “error_reporting = E_ALL & ~E_NOTICE


will prevent PHP from throwing warnings concerning notices and coding standards.
Now save and close the php.ini file and restart your server.



  • Change the deprecated code

This example is only suitable in the case of amfphp and wampserver, of course the method of changing the deprecated code will work in other cases as well. You can use this code as an example to alter the deprecated code in other cases.

So, in the case of amfphp the deprecated code is located in the MethodTable.php file. At line 505 to be exact.
You will find the MethodTable.php file at “C:\wamp\www\amfphp\core\shared\util\” ,

assuming your wampserver is placed at the root of your C drive and amfphp at the root of your webserver. Anyway, when the warning message gets thrown, the exact location of the MethodTable.php file is mentioned. When found, open the MethodTable.php file in an editor and alter the following.
Go to line 505 and remove, or comment, the following lines of code :

$comment = eregi_replace(“\n[ \t]+”, “\n”, trim($comment))
$comment = str_replace(“\n”, “\\n”, trim($comment));
$comment = eregi_replace(“[\t ]+”, ” “, trim($comment));
Then replace it with the following code, using the equivalent function preg_replace() :
$comment = preg_replace(“`\n[ \t]+`U”, “\n”,trim($comment));
$comment = str_replace(“\n”, “\\n”, trim($comment));
$comment = preg_replace(“`[\t ]+`U”, ” “,trim($comment));


Save and close the MethodTable.php file. Restarting your webserver is not necessary but is a good idea.
These solutions should have resolved the deprecated eregi_replace()issue.
Code on !

No comments:

Post a Comment