Introduction to PHP
What is
PHP?
- PHP stands for PHP: Hypertext Preprocessor
- PHP is a server-side scripting language, like ASP, Coldfusion, Perl
- PHP is a programming language was designed for creating dynamic websites
- PHP supports many databases like MySQL, Informix, Oracle, Sybase, Solid, PostgreSQL, Generic ODBC, etc.
- PHP is an open source software and you can download free from www.php.net.
- PHP is easy to learn and runs efficiently on the server side
- PHP runs on different platforms like Windows, Linux, Unix, etc.
- PHP is compatible with almost all servers used today like Apache, IIS, etc.
What is
an PHP File?
An PHP file is a text file that contains HTML, XML Tags, Text and scripts. The
scripts in PHP files are excuted on the server. The file extension of PHP file
is ".php".
PHP Requirements
- Install Apache Web Server on Windows, unix or linux operatings system you can download Apache web server from http://httpd.apache.org/download.cgi
- Then insall PHP on Windows, unix or linux operatings system you can download PHP software from http://www.php.net/downloads.php
- Install MySQL on Windows, unix or linux operatings system you can download PHP software from http://www.mysql.com/downloads/index.html
PHP Tags
PHP has following tags:
| Start Tag | End Tag |
| <?php | ?> |
| <script language="php"> | </script> |
| <? | ?> |
| <% | %> |
First PHP Script
For write first script of PHP, Open notepad. Type the below example and save the file at C:\apache\htdocs\filename.php,
print "Hello World!";
?>
In this script <?php is used for start PHP tag.
print is used to print any statement on page. Another function echo is also to print any statement on page.
semicolon (;) is used for end any statement .
?> is used for end php script
Comments in PHP
Comments are used for ignore any statements.There are two comment tags used in PHP.
// (Single Line Comments ) will comment out a single line of coding.
// print some text
print "my first PHP script!";
?>
/* */ (Multiple Line Comments ) will comment out a block of code.
/*
print some text
this is a comment
over more than one line
*/
print "my first PHP script!";
?>
