.PHP - File Extension for PHP: Hypertext Preprocessor Files

Q

What is PHP? PHP, short name for PHP: Hypertext Preprocessor, is used as the file extension for PHP script code files. .PHP files are text files that can be opened by any text editors. See the sample .PHP file included below.

✍: FYIcenter.com

A

File Extension: .PHP

MIME Type: text/plain

File Content: PHP: Hypertext Preprocessor

.PHP files are PHP: Hypertext Preprocessor files, which contains PHP script codes. Here is a sample .PHP file with a simple script code:

<?PHP
 if (isset($_POST ["file"])) {
   $FileName = $File = $_POST ["file"];
 } else {
   $FileName = "";
 }
?>

<HTML>
<BODY BGCOLOR=#FFFFFF>

<FORM ACTION=/cgi-bin/cgiwrap/username/Example.php METHOD=POST>

<P>Enter FileName:
<?PHP
  echo " <INPUT TYPE=TEXT NAME=file VALUE=\"$FileName\" SIZE=75>\n";
?>
<P><BR><P>
<INPUT TYPE=SUBMIT VALUE="Show Me!">

</FORM>

<P><BR><P>
<P><BR><P>
<P><BR><P>

<?PHP
 if (isset($File)) {
   $Handle = @fopen ($File, "r"); // '@' suppresses external errors

   if ($Handle) {
     $FileText = fread ($Handle, 10000); // Read up to 10,000 Bytes

     fclose ($Handle);

     // Fix HTML tags that may be there

     $SafeText1 = str_replace ("&", "&", $FileText);
     $SafeText2 = str_replace ("<", "<", $SafeText1);
     $SafeText  = str_replace (">", ">", $SafeText2);

     // Now it is safe to display it

     echo " <H2 ALIGN=CENTER>File: $File</H2>\n";

     echo "<PRE>\n";
     echo $SafeText;
     echo "</PRE>\n";
   } else {
     echo " <H3>Error: File '$File' is not accessible.</H3>\n";
   }
 }
?>

</BODY>
</HTML>

.PHP PHP: Hypertext Preprocessor file sample: Click sample.php to download.

Since .PHP text files are in text format, you can use Notepad or any text editor to create or modify them. No special software is needed.

For for information on how to use .PHP PHP: Hypertext Preprocessor files, see links below:

2012-07-08, 3676👍, 0💬