We place comments in PHP code to make the code more maintainable and readable. These comments will not be viewable to the public, only to the person editing the PHP file. To comment in PHP we should prefix ‘//’ to our comment, for example:
<?php
//This is our comment
?>
We can also place comments over multiple lines by using ‘/*’ to begin and ‘*/’ to end our comment – as shown below.
<?php
/* This is a
comment set
over multiple
lines */
?>
Comments will be a lot more useful when more advance techniques in PHP are used.
A basic page in PHP is shown below, using our start, and end tags as well as comments. Please note that nothing will show, as comments are being used.
<html>
<head>
<title>First PHP Comments</title>
</head>
<body>
<?php
// This is a comment and will not be shown to the public
/* This is a multi-line comment and will not be shown
to the public */
?>
</body>
</html>
PHP Comments
(from Full Article)
We place comments in PHP code to make the code more maintainable and readable. These comments will not be viewable to the public, only to the person editing the PHP file. To comment in PHP we should prefix ‘//’ to our comment, for example:
We can also place comments over multiple lines by using ‘/*’ to begin and ‘*/’ to end our comment – as shown below.
Comments will be a lot more useful when more advance techniques in PHP are used.
A basic page in PHP is shown below, using our start, and end tags as well as comments. Please note that nothing will show, as comments are being used.