Monday,November,26th,2012by Jhalak Subedi
PHP doesn’t cost anything . It is available free from php.net for commercial use or whatever.PHP alongwith MySQL database and APACHE server provides a comprehensive way of developing the web applications.Now PHP supports myriad number of databases and servers.Lots of tools and frameworks that are alive today utilizes the power of PHP.
How to install PHP
For learning purpose we need to install a PHP package which includes everything -the server and the database.
It depends on what machine you are using. If you are on WINDOWS then there’s a package called WAMP which includes everything mentioned above.On LINUX you can use LAMP(LINUX APACHE MySQL PHP) and on MAC there’s MAMP(MAC APACHE MySQL PHP) for you. After successful installation your local machine behaves like a server and you can run PHP commands.
PHP “Hello World!!”
1) Open your favorite text editor and type in the following code:
<?php echo "Hello world"; ?>
2) And save it as index.php by creating a folder inside the root folder. If you are using WAMP then navigate to WWW directory (c:\wamp\www\myfolder\)
3) Then type the URL inside the browser input field like(localhost/myfolder/index.php) and it will give you the desired outpt which is printing hello world to the screen.
Well its the very basic script,nothing complicated here. First line of code says the beginning of the PHP script and the echo command used in the second line is for printing any text to the screen. The code in the second line is actually a statement so it is terminated by a semicolon.The text is wrapped inside quotes to mark that it is a string and remember that you could also use the single quote. The last line of code simply ends the php section.