![]() |
VOOZH | about |
PHP, a powerful server-side scripting language used in web development. It’s simplicity and ease of use makes it an ideal choice for beginners and experienced developers. This article provides an overview of PHP syntax. PHP scripts can be written anywhere in the document within PHP tags along with normal HTML.
PHP code is executed between PHP tags, allowing the integration of PHP code within HTML. The most common PHP tag is <?php ... ?>, which is used to enclose PHP code. The <?php ....?> is called Escaping to PHP.
The script starts with <?php and ends with ?>. These tags are also called 'Canonical PHP tags'. Everything outside of a pair of opening and closing tags is ignored by the PHP parser. The open and closing tags are called delimiters. Every PHP command ends with a semi-colon (;).
Hello, world!
PHP code can be embedded within HTML using the standard PHP tags. In this example, the <?php echo "Hello, PHP!"; ?> statement dynamically inserts a heading into the HTML document.
These are the shortest option to initialize a PHP code. The script starts with <? and ends with ?>. This will only work by setting the short_open_tag setting in the php.ini file to 'on'.
Example:
Output
Hello, world!PHP is partially case-sensitive-
Example:
Comments are used to make code more readable by explaining the purpose of specific code blocks. Comments are ignored by the PHP interpreter.
As the name suggests, these are single line or short relevant explanations that one can add to their code. To add this, we need to begin the line with (//) or (#).
Hello World!
Output:
hello world!!!It is used to accommodate multiple lines with a single tag and can be extended to many lines as required by the user. To add this, we need to begin and end the line with (/*...*/)
Hello World!
Variables are used to store data that can be manipulated within PHP. They are declared using the $ symbol followed by the variable name.
Variables are created by assigning a value to them using the assignment operator (=).
PHP supports several data types, including:
In PHP, multiple statements can be executed simultaneously (under a single condition or loop) by using curly-braces ({}). This forms a block of statements that gets executed simultaneously.
Positive as greater than 0