Sunday 28 October 2012

Basic PHP Syntax | Lesson 2

Before we begin, first confirm that, your server supports php ? 

If yes, then every thing is fine. 

If no, then install php by following this tutorial :- 

www.php.net/manual/en/install.php


Lets Come to our Topic :-

[
Note:- In my whole lessons, I'll be using free hosting 3owl.com to execute php scripts. 
]

Php scripts begins with <?php and ends with ?> just like in html, we use <html> to begin the script and </html> to end script. 

A php file is a mixture of html tags and php script. We save it as xyz.php.

Here is a simple example, this will make you to understand it easily :-

<html>
<head>
<title>Lesson-2</title>
</head>
<body>
<?php
echo "Lesson 2 | Road to PHP";
?>
</body>
</html>

In above example, <html>, <head>, <body> are html tags and 
echo is used to print the output.
" " anything, which is inside the " " will be print as a message.
; and colon is used to end the statement.


Output of the above example will be 

Lesson 2 | Road to PHP

How to put Comments in PHP ? 

In php, we can put One Line Comment by // < comment > and Comment Block /* < comments > */ (unlimited lines).

Example:-

<html>
<head>
<title>Lesson-2</title>
</head>
<body>
<?php

//This is one line comment

/*
This is one 
block comment

*/

?>
</body>
</html>


I hope this post have helped you :p
Stay Tunned.

First Step Towards PHP

What is PHP ?

PHP stands for Hypertext Preprocessor. This is one of the most popular sever side scripting language, like as ASP and JSP.


What is Extension of PHP files ?

PHP files can be saved as php or phtml or php3.


Features ?


  • Open Source
  • Supports many database
  • Can execute programming scripts of other languages


From Where Should I Download PHP ?




How To Execute PHP File ?


As I said above, PHP is a server side Scripting Language. So you must have to install Apache server or IIS or you can register for free hosting.