What is PHP using an example

 

PHP is a server side Hypertext Preprocessor scripting language which helps us to create dynamic online websites.PHP is an open source language which is easy to learn and execute, with the combination of HTML, CSS, JQuery, Javascript, Database Engine and PHP you can create any dynamic content website in a quick time as compared with other languages.

 

PHP is free and can be downloaded from its official website http://www.php.net.


Why PHP ?

  • PHP is Free, easy to learn and understand the syntaxes.
  • PHP helps to create dynamic content websites.
  • PHP can be installed in Linux, IIS, MAC OS and many more.
  • PHP can run on IIS, Apache and many more.
  • PHP hosting is cheaper when compared with other language hostings
  • PHP supports multiple databases like MS-SQL, MYSQL, Oracle and PostgreSQL.

How to start with PHP

To get started with PHP 1st step you need to download the following

 

For Windows

Downlaod WampServer (WAMP) - This will install Apache, MYSQL and PHP for windows

For Linux Downlaod LAMP - This will install Apache, MYSQL and PHP for Linux

Now if you want to use database MS-SQL or Oracle then do manual step up from its official website http://www.php.net.


About PHP Editor

To do the php coding either you can use phpedit is the best PHP IDE from (www.phpedit.com), Dreamweaver and many more.


Extension to save PHP files is

*.php

Before you start installing PHP make sure that you have created "www" in your storage drive because while installing PHP you need to point to "www" as your root directory.

So that you can save all your php files in "www" directory for each website development.

Note: Kindly make sure that whenever you want to create a new website create "www" directory in same drive where your old "www" directory exist. Rename the old one with some other name and then create new "www" directory.


Syntax of PHP

PHP is starts with "

"<?php " and ends with "?>" - for best practices use same style as i shown you here.

 
<?php

///PHP code starts here

?>

Note : Do not use "<?"..."?>", "<?PHP"..."?>" to start.keep best practices by using "<?php"..."?>"


Default PHP File in Web Server

index file is the default file in php


Simple Example using php to display color names in an ordered list.

 

<html>
<head>
<title>Displaying Color Names</title>
</head>
<body>

<?php

echo "<ol>";
echo "<li>Yellow</li>";
echo "<li>Green</li>";
echo "<li>Blue</li>";
echo "<li>Red</li>";
echo "<li>Violet</li>";
echo "<li>Brown</li>";
echo "</ol>";

?>

</body>
</html>


As you see from our above code that we have successfully displayed the color names in an ordered list using PHP script embeded with HTML.


echo in PHP

echo is a language construct does not required parentheses. It simply used to output the string or simply used to print variable values.

So i hope that you have understood how to start with PHP, PHP is simple, easy to learn language.so start your PHP today and created dynamic websites. so if you have any doubts or query kindly let me know.

 

 

:: SHARE THIS POST ::

        
 
Author: Gurunatha Dogi
is a software engineer by profession and founder of Onlinebuff.com, Onlinebuff is a tech blog which covers topics on .NET Fundamentals, Csharp, Asp.Net, PHP, MYSQL, SQL Server, Cell Phones and lots more. Follow me @ and twitter.
Leave a Comment......

All fields marked with * are mandatory

eqsn1

 

 
Comments

Posted by Renuka Bhanarkar on 2016-05-06

How to populate one dropdown from another dropdown using php mysql ajax ? pl explain in detail . Thanks .

Posted by Shakir ali on 2014-08-20

lovley

Posted by Suffian ahmed on 2014-03-20

Hi, Very nice blog and interview topics covered intelegently. Keep it up. Regards Suffian Ahmed