1. TTfile
  2. PHP File

PHP File

PHP file is the source code of PHP language.

PHP is currently one of the most common server-side scripting languages. It is very popular for developing web based software applications because programmers can use it easily to create web pages with dynamic content that interact with databases. The PHP source code is written by web developer and is processed on the web server, which dynamically generates HTML. The HTML, which contains the web page content, is then sent to the user's web browser. Therefore, the user should never see the actual PHP source code but only the web page.

PHP file is the source code of PHP language which contains text, HTML tags, and scripts. It is returned to the browser as plain HTML. Besides, PHP files always have filename extensions of “.php”, “.php4”, or “.php5.”

Reading from and writing to files is one of the most common programming tasks. You can't process data if you don't get it from somewhere (most often a file), and you will usually need to store the result of the processing in something different from the volatile RAM. Again, one of the most common solutions is a file, in which you write the result of the processing. Of course, if you want to be able to read and write to files, you need to know how to open them.

Open a File in PHP as Read-Only

Step 1

Use the 'r' option to open a file as read-only. When a file is opened as read-only, the file pointer is placed in the beginning of the file and you start reading from there.

1

Step 2

Use the more advanced way, with the 'r+' option, to open a file for reading. The 'r+' option opens a file for both reading from and writing to. As with the 'r' option, the file pointer is at the beginning of the file.

2

Open a File as Write-Only

Step 1

Use the 'w' option, to open a file as write-only. It is important to note that this option erases the contents of the file, places the pointer in the beginning of the file and starts writing from there.

3

Step 2

Use the more advanced way, the 'w+' option, to open a file for writing. The 'w+' option opens a file for both reading from and writing to. The difference with 'r+' is that the 'w+' option deletes all information in the file when the file is opened.

4

Open a File for Appending

Step 1

Use the 'a' option to open the file for writing. The data in the file is not deleted, and the file pointer is placed at the end of the file so that you start writing the new contents after the existing data.

5

Step 2

Use the more advanced 'a+' option to open the file for appending. The difference with 'r+' is that the file pointer is positioned at the end of the file.

6

XML (eXtensible Markup Language) is a convenient way of writing human-readable data sets which can also be shared between computer systems that might otherwise be incompatible with each other. PHP is a powerful scripting language with a large and growing user base. By converting an XML file to PHP, you will be able to modify your data in real-time from the server, then use the data in a variety of dynamic applications.

A Simple Example with SimpleXML

Step 1

Create an XML file named "inventory.xml" in a folder named "includes." It will look something like this:

1

Step 2

Save a duplicate copy of your document named "inventory.php." Add the PHP open and closing tags at the beginning and end of this document.

Convert your XML nodes into a string and assign them to a variable named $xmlString. You can do this simply by wrapping your existing XML in a few special characters: at the beginning, three "less than" signs in a row, followed by the letters XML; and after the closing of your root node, the letters XML again. Remember to finish your assignment statement with a semicolon. Your document will now look like this:

2

Step 3

Create another document named "display-inventory.php" and save it in the folder one level above your "includes" folder. This script will include your converted XML file, use it to create a SimpleXMLElement object, and read out the node values into paragraphs.

3

Upload the files to your server and view the file view-inventory.php in your web browser. It will output:

4

Step 4

You can make your XML string more dynamic by using variables to set the values of the nodes. Create a variable named $variable with a value of "hex," then read out the variable's value into the node of your XML string:

5

Step 5

Alternatively, you can load your XML into PHP without converting the file into a string. Upload your original file inventory.xml to your server, and amend your script to read:

6

Post the revised file to your server, and you should see results similar to the first example.

The PHP Group aids in managing PHP guidelines because there are no formal specifications that outline PHP. PHP was created in 1995 by Rasmus Lerdorf, and originally stood for Personal Home Page. PHP is a scripting language that is suited for web development, and it can be embedded in HTML. For PHP to work properly it is usually installed on a server. The user uploads the PHP files to the server and can run them from their site.

Step 1

Open a simple text editor by clicking Start>>All Programs>>Accessories>>Notepad/Wordpad. It is best to use something like Notepad or Wordpad. Microsoft Word and other higher level word processors add a lot of extra formatting that can get in the way of writing or saving code-oriented files.

1

Step 2

Enter your PHP code. Remember, for the code to be read properly you must have "" (no quotes) at the end. For example:

2

Step 3

Save the file use the File>>Save As... feature to save the file to your desktop as a .txt file.

3 5

Step 4

Navigate to the file you just created.

6

Step 5

Right-click the file and rename it. Change the extension from ".txt" to ".php". You have created a PHP file.

7

While the Notepad program that comes installed with Windows Vista can open many PHP files for in-line editing, a free application called Notepad2 adds flexibility and compatibility. Notepad2 also features syntax highlighting, allowing you to edit your PHP script with fewer typos or mistakes.

Step 1

Download the Notepad applicatio. You will need to unzip the ZIP file using a program such as WinZip.

Step 2

Open the EXE file in the Notepad folder. No additional installation is necessary.

Step 3

Select Open from the Notepad File menu. Find the PHP file you wish to edit on your PC and click the Open button. The text of your PHP file will come up, with syntax highlighting using different colors and fonts. These simply provide a visual aid for editing and do not change the content of the actual file.

8

Step 4

Save your file when you are finished. It is recommended you create a new PHP with each save, so you can revert to a previous version if you make a mistake.

Portable Document Format (PDF) is a file format created by Adobe Systems in 1993 for document exchange. PDF is used for representing two-dimensional documents in a manner independent of the application software, hardware, and operating system.

PHP: Hypertext Preprocessor (the name being a recursive acronym) is a widely used, general-purpose scripting language that was originally designed for web development to produce dynamic web pages. For this purpose, PHP code is embedded into the HTML source document and interpreted by a web server with a PHP processor module, which generates the web page document.

In this guide, you will see how to convert PHP to PDF document with AZ Document to PDF Converter, which can convert up to 2000 PHP files to PDF with seconds.

AZ XML to PDF Converter is an extrodinary document to PDF conversion software that helps you make PDF documents easily with a variaty of document formats including XML, HTML, HTM, TXT, PHP, ASP. 2000 documents maximum are allowed in a conversion task.

Before you start to read this guide, please ensure you have downloaded and install the AZ Document to PDF Converter. You can download it at here.

Instructions

Step 1-Add PHP files

Click Add File(s) to add the documents you want to convert to the list.

Click Add Dir to add a directory to the list.

1

Step 2-Set up parameters

Click Mode Up or Mode Down to change the file orders as you like.

2

Step 3-Start to convert PDF

Click Convert to PDF to start conversion.

3