Mixing PHP/HTML and Commenting in PHP


The primary use of PHP is to build websites and web applications. Since browsers use HTML and JavaScript to render websites, the output generated by PHP is in HTML. The HTML codes that you see in websites like Facebook are the output after PHP processed it.

PHP code is mixed with HTML tags to produce the desired output. You save such files with a .php extension. You can even save files with just html with a .php extension and they still work.

You can also mix HTML within the PHP code in the following way:

Notes:

  1. Every line of PHP code ends in ; (semi-colon).
  2. Line breaks do not matter as long as you get the syntax right.

Commenting in PHP

If you want to insert notes and comments in PHP to make the code easily understandable here’s how you do it:

Single line comments begins with // or #. Double slashes are more common.

Example:

Multiple line comments: Begins with /* and ends with */

Example:

Note: Nothing is returned in the browser from these comments.

You may also like

Comments are closed here.

Advertisements

Subscribe to Blog via Email

Enter your email address to subscribe to this blog and receive notifications of new posts by email.

Join 2 other subscribers