AMFPHP and PHP 5.3 bugfix

AMFPHP and PHP 5.3 bugfix

Hey geeks,

Personnaly I love working with AMFPHP in combination with Flash or Flex applications. When I was preparing a job interview I faced alot of problems with the new version of PHP5. Off-course my first reflex was to google for a solution and I found alot of information that I like to share with you.

First of all I installed the amfphp on WAMP server (Xampp refused to work with amfphp). Installing AMFPHP is easy as pie, just extract the amfphp rar file on your local web server in the www folder. Next you can surf to the service browser via local address: http://localhost/amfphp/browser/

When accessing the browser you get the following error:

Error retrieving service info:

Function eregi_replace() is deprecated
C:\${Your_address}\amfphp\core\shared\util\MethodTable.php on line 513

The reason that you are getting this error is because eregi_replace() function in PHP 5.3 has changed. So it is just a syntax that need to be changed. If you want to fix this manually you need to browse to “MethodTable.php” using your windows explorer and open it using your texteditor. I suggest you to useĀ  Notepad++ because you need to search for line 513. If you are using notepad you cannot search for a specific line, as far as I know.

When you have found line 513 you need to replace the following three lines:

$comment = eregi_replace("\n[ \t]+", "\n", trim($comment));
$comment = str_replace("\n", "\\n", trim($comment));
$comment = eregi_replace("[\t ]+", " ", trim($comment));

into:

$comment = preg_replace("\n[ \t]", "\n", trim($comment));
$comment = str_replace("\n", "\\n", trim($comment));
$comment = preg_replace("[\t ]", " ", trim($comment));

when you pasted the lines above, all you need to do is save the file and refresh your WAMP server.

If you do not have the time to change this file manually or if you are just a lazy person like almost every programmer then just download the file below and replace him with the old ‘MethodTable.php’ file.

Download fixed methodTable.php

Have fun coding!

Lode


Also interesting reads:
  1. Upload Multiple Files with ActionScript 3
  2. File Deletion with ActionScript 3.0 and PHP

About the Author

Lode is a Creative-Geek with passion for Graphic design , he is also into the web programming "stuff" like Adobe Flash,air and Flex . Lode loves to learn and loves to share knowledge with others.Follow Lode on http://twitter.com/stealfish