PHP – Basics and Comments

Syntax

PHP files are saved with the extension of  .php , for example index.php. Here index is the file name. Next is how to write a php commands? For writing php program we can use any type of notepad software.

  • PHP programs are type with in  <?php for starting and end the code with ?>.
  • The end tag ?> is optional when the file contain only php code.

Next is how to print a simple word using php.

  • echo is used to output the data to browser.

So many variables are used in php. Before using the variables the programmer must initialize the variable. If the variable used before initialization it produce syntax errors with in the program. So it is one major task of programming, this is not only for php language. it is a common objective of programming. I think viewers get the importance of variable initialization. so now I explain how to initialize a variable with in a php programming language. The symbol ‘$‘ is used to initialize a simple variable. A simple example expressed given below.

Comments

Comments are major part of the programming. Every notes written by a programmer with in a comment line. If a user wants to write some brief description inside the code without any changes in the code, the programmer use comment line. It is mainly used to find the errors and documentation.

There is mainly three types of comment lines used in php programming.

  1. //   (for line comments)
  2. #    (for line comments)
  3. /*   */  for block comment
  • // and # are mainly used to comment a single line and /*  */ is used to comment more than one line.
  • Here /* for starting the comment line and /* for end the comment line.

Leave a Reply