TestingDocs.com
Software Testing website
  • Automation
    • Selenium
    • JBehave Framework
  • Tutorials
    • MySQL Tutorials
    • Testlink
    • Maven
    • Git
  • IDEs
    • IntelliJ IDEA
    • Eclipse
  • Flowcharts
    • Flowgorithm
    • Raptor
  • About

PHP

PHP Comments

Overview

We can use PHP Comments to explain the PHP code to others. Comments are ignored by the PHP Interpreter and the web browser.

Single Line Comment

Single line comment can be added in PHP code using the double forward slash //.

Syntax

<?php
// This is single line PHP comment
?>

Multi-line Comment

We can also use multi-line comments in PHP Code. To start a multi line comment, a forward slash and an asterisk (/*) is used. To end it an asterisk and a forward slash (*/) is used.

Syntax

<?php
/* This is a multi line comment in PHP example
This will be ignored by the PHP interpreter
and the web browser */
?>

Example


<!DOCTYPE html>
<!–
PHP Comment Demo
–>
<html>
<head>
<meta charset=”UTF-8″>
<title>PHP Comment Demo</title>
</head>
<body>
<h1> PHP Comment Demo </h1>
<?php
//Sample PHP Code single Line comment
echo “Hello, This page can run PHP code! \n”;
?>
<br>
<br>
<?php
/*
This is a multi-line PHP comment.
Both the single-line and multi-line comments
would be ignored by PHP preprocessor and
web browser.
*/
echo “\n Notice that none of the PHP comments will appear here..”;
?>
<h1>PHP Tutorials </h1>
<h3>www.TestingDocs.com</h3>
</body>
</html>


Sample Output

 

PHP Comments

Code Editors generally highlight comments in different color to visually separate it from the code.

 

PHP Comment Output

Notice that none of the comments are displayed by the browser.

 

—

PHP Tutorials

PHP Tutorials on this website:

https://www.testingdocs.com/php-tutorials/

More Information on PHP

https://www.php.net/

Related Posts

Compoer Command line command

PHP /

Install Slim Framework on Windows

php download website

PHP /

Download and Install PHP on Windows

Composer Install Windows

PHP /

Composer Download on Windows

Apache conf file

PHP /

PHP 7 Configuration in Apache Server

testing php linux

PHP /

Testing PHP with Apache Server on Linux

‹ PHP Script Syntax› PHP Variables

Recent Posts

  • MS Access Data Types
  • Install RAPTOR Avalonia on CentOS
  • Download RAPTOR Avalonia Edition on Windows
  • npm doctor command
  • Build & Run CLion Project
  • Create New CLion C Project on Windows
  • Configure CLion Toolchains on Windows
  • Launch CLion IDE on Windows
  • Activate CLion IDE
  • CLion IDE for C/C++ Development

Back to Top

Links

  • Contact
  • Privacy Policy
  • Cookie Policy

www.TestingDocs.com

Go to mobile version