Although PHP is not the most powerful programming language, it is one of the most widely used for creating dynamic web pages. That’s because it is supported by most web hosting platforms (if not all). Here are the benefits of learning and using PHP for creating dynamic web pages.
- PHP is a server side scripting language widely use for creating dynamic web pages.
- PHP is free and open source and it can run on most shared servers.
- PHP scripts are executed on the server and return to the browser as plain text.
- PHP stands for “PHP: Hypertext Preprocessor”.
- PHP files have “.php” extension.
- PHP can generate dynamic page content.
- PHP can create, open, read, write, delete, and close files on the server.
- PHP can collect form data.
- PHP can send and receive cookies.
- PHP can add, modify and delete data on the database.
- PHP can control user access.
- PHP can encrypt data.
- PHP can output HTML, XHTML, XML, images, PDF files etc.
- PHP runs on various platforms (Windows, Linux, MacOS etc).
- PHP is compatible with most servers used today.
- PHP supports most databases used today.
A PHP script can be place anywhere in a document. It starts with
<?php and ends with
.php file contains HTML code and some PHP code. Every PHP statement ends with a semicolon.
A basic example will be:
<!DOCTYPE html> <html> <body> <h1>I am learning PHP</h1> <?php echo "PHP is easy! … and cool!"; ?> </body> </html>
You can use comments in your PHP code as in any other programming language. Here is an example:
<!DOCTYPE html> <html> <body> <?php // This is a single-line comment # single-line comment /* multiple-lines comment spans over multiple lines */ // leave out parts of a code line $x = 3 /* + 11 */ + 2; echo $x; ?> </body> </html>
In PHP only variables are case sensitive, everything else is not.
PHP is easy to learn and use, it is very powerful and it powers the vast majority of the website on the Internet. It is well documented and there are many resources available online.