PHP: Easy Dynamic Websites
PHP is a very popular language used for the purpose of scripting. It is widely used because it allows the creation of dynamic websites in a quick and simple manner. The basics of PHP are easy to learn, especially if you are thorough with any other programming language. Even if you are not, it will not take much of your precious time and effort.
Basics of PHP
According to the programming tradition, the first thing that is done with the use of any language is to say 'Hello World'. In PHP this is done as follows. The first step is to create a file with the name index.php in the root directory of the server, containing this text:
<?php
echo "Hello World";
?>
The first line specifies that it will be followed by a PHP code. The 'echo' command is used to send the text to the browser. Each line of PHP ends with a semicolon. The last line specifies the 'end of the PHP code'.
The PHP tags can be inserted anywhere in a HTML document as many times as you like. The PHP code can connect to the database and read the text into a template along with other things such as author's name, date and headline.
Some useful PHP Functions
Some of the most used PHP functions are:
echo: It is used to write text in the document. The shortcut of <?php echo is <?= .
date: It is used to display the date in the specified format. For example, date("D j M Y") shows the date as: Mon 12 Feb 2007.
fread: It is used to read the file's content.
fopen: It is used to open a file on your web server, or for opening a URL and connection with another server.
mysql_connect: It is used to connect to a MySQL server. The location of the server as well as the username and password needs to be specified.
mysql_query: It is used to send the SQL commands to the MySQL server.
mysql_select_db: It is used to open a particular MySQL database on the MySQL server.
explode: It is used to divide the text into array by searching 'separators'. It can be useful in case characters like | is used to separate data in your program.
str_replace: It is used to replace a particular word with another.
md5: It takes text and produces a 'hash' using the MD5 algorithm. It is used to check user's passwords without saving them in a database in a plain text.






















