About PHP, syntax, comments and code

About PHP, syntax, comments and code
5 (100%) 1 vote

What is PHP?

  • PHP (acronym for Hypertext Preprocessor) is the most popular server-side, open source scripting language, used to build dynamic website.
  • PHP scripts are executed on the server.
  • PHP runs on various platforms (Windows, Linux, Unix, Mac) and is compatible with almost all servers available today (Apache, IIS, …)

 

What is a PHP File?

  • PHP files have the extension “.php”.
  • PHP files are executed on the server and the result is returned to the browser as simple HTML.
  • PHP files may contain besides PHP code, also HTML, CSS or JavaScript.

 

About PHP syntax

The PHP script can be placed anywhere in the document and must begin with <?php and ends with ?>, as follows:

<?php
// PHP code goes here
?>

Remember: all PHP statements must end with a semicolon (;).

 

About PHP comments

Unlike Html comments, PHP comments will not be displayed to your visitors, who may view your website’s source code.

PHP comments serve as explanatory notes and are only useful for PHP programmers, because the only way to view them is by opening the PHP file for editing.

PHP comments are lines that are not read/executed as part of the program.

PHP supports two types of comments:

  • single-line comment;
  • multiple-lines comment block;
<?php
// This is a single-line comment

# This is also a single-line comment

/*
This is a multiple-lines comment block
that spans over multiple lines
*/
?>

 

PHP Case Sensitivity

In PHP, all keywords (if, else, while, switch, echo, …), classes and functions are NOT case-sensitive, while all variable names are case-sensitive.

Leave a Reply

Your email address will not be published. Required fields are marked *