PHP Code Formatting Demo


FormatCode Code Formatter is based on serveral powerful syntax parser engines so you can exactly control the appearance of your source code. Here is the code formatting demo of FormatCode PHP Code Formatter to prove the ability of code formatting functions of FormatCode:

   <?php

   //--- Before Code Formatting ---

   echo'Your IP is ',GetIP(),'<br /><br />';function GetIP(){$realip="";if(isset(
   $_SERVER)){if(isset($_SERVER["HTTP_X_FORWARDED_FOR"])){$realip=$_SERVER[
   "HTTP_X_FORWARDED_FOR"];}elseif(isset($_SERVER["HTTP_CLIENT_IP"])){$realip=
   $_SERVER["HTTP_CLIENT_IP"];}else{$realip=$_SERVER["REMOTE_ADDR"];}}else{if(
   getenv('HTTP_X_FORWARDED_FOR')){$realip=getenv('HTTP_X_FORWARDED_FOR');}elseif(
   getenv('HTTP_CLIENT_IP')){$realip=getenv('HTTP_CLIENT_IP');}else{$realip=getenv
   ('REMOTE_ADDR');}}return $realip;}
   ?>


   <?php

   //--- After Code Formatting ---

   echo 'Your IP is ', GetIP(), '<br /><br />';

   function GetIP()
   {
     $realip = "";

     if (isset($_SERVER))
     {
       if (isset($_SERVER["HTTP_X_FORWARDED_FOR"]))
       {
         $realip = $_SERVER["HTTP_X_FORWARDED_FOR"];
       }
       elseif (isset($_SERVER["HTTP_CLIENT_IP"]))
       {
         $realip = $_SERVER["HTTP_CLIENT_IP"];
       }
       else
       {
         $realip = $_SERVER["REMOTE_ADDR"];
       }
     }
     else
     {
       if (getenv('HTTP_X_FORWARDED_FOR'))
       {
         $realip = getenv('HTTP_X_FORWARDED_FOR');
       }
       elseif (getenv('HTTP_CLIENT_IP'))
       {
         $realip = getenv('HTTP_CLIENT_IP');
       }
       else
       {
         $realip = getenv('REMOTE_ADDR');
       }
     }

     return $realip;
   }

   ?>


Click here to preview the PHP Code Formatting Demo 2.

With FormatCode PHP Code Formatters, you can format and transform any foreign PHP source code to meet your preferred coding style or any common code convention in several seconds!