Learn Basic PHP Syntax

Basic PHP Syntax in this post I’m going to share How  Learn Basic PHP Syntax  so you will be write your own first PHP script , before you write your first PHP script you have to know the PHP script can be placed anywhere in the document and PHP script starts with

and default file extension for PHP files is “.php”. for example if you are create first page in PHP and you give your page name index then this index extension will “index.php”

Learn PHP Programming Step by Step Guide for Beginners

The Basic PHP Syntax are as follows

Comments in PHP

A comment in PHP code is a line that is not read/executed as part of the program. Its only purpose is to be read by someone who is looking at the code.

Comments can be used to:

Single-line comments − They are generally used for short explanations or notes relevant to the local code. Here are the examples of single line comments.

Multi-lines comments − They are generally used to offer pseudocode algorithms and more detailed explanations when necessary. The multiline style of commenting is the same as in C. Here are the example of multi lines comments.

Let others understand what you are doing remind yourself of what you did – Most programmers have experienced coming back to their own work a year or two later and having to re-figure out what they did. Comments can remind you of what you were thinking when you wrote the code

PHP Case Sensitivity

In PHP, all keywords (e.g. if, else, while, etc.), classes, functions, and user-defined functions are NOT case-sensitive.

In the example below, all echo statements below are equal.

This will produce the following result

 

But all  variable names are case-sensitive in PHP.

In the example below, only the first variable will display the value of the $color variable this is because $color, $COLOR, and $coLOR are treated as three different variables

This will produce the following result

feel free to share it with your friends on Facebook ,twitter,Google+

Leave a Reply