PHP Comments
نشر بتاريخ 2024-05-17 07:14:49
0
2كيلو بايت
Comments in PHP
A comment in PHP code is a line that is not executed as a part of the program. Its only purpose is to be read by someone who is looking at the code.
Comments can be used to:
- Let others understand your code
- Remind yourself of what you did - Most programmers have experienced coming back to their own work a year or two later and having to re-figure out what they did. Comments can remind you of what you were thinking when you wrote the code
- Leave out some parts of your code
PHP supports several ways of commenting:
ExampleGet your own PHP Server
Syntax for comments in PHP code:
// This is a single-line comment
# This is also a single-line comment
/* This is a
multi-line comment */
Try it Yourself »Single Line Comments
Single line comments start with //
.
Any text between //
and the end of the line will be ignored (will not be executed).
You can also use #
for single line comments, but in this tutorial we will use //
.
The following examples uses a single-line comment as an explanation:
Example
A comment before the code:
// Outputs a welcome message:
echo "Welcome Home!";
Try it Yourself »Example
A comment at the end of a line:
echo "Welcome Home!"; // Outputs a welcome message
Try it Yourself »Comments to Ignore Code
We can use comments to prevent code lines from being executed:
PHP Exercises
البحث
الأقسام
- Art
- Causes
- Crafts
- Dance
- Drinks
- Film
- Fitness
- Food
- الألعاب
- Gardening
- Health
- الرئيسية
- Literature
- Music
- Networking
- أخرى
- Party
- Religion
- Shopping
- Sports
- Theater
- Wellness
إقرأ المزيد
PHP Associative Arrays
PHP Associative Arrays
Associative arrays are arrays that use named keys that you assign to...
PHP - Escape Characters
Escape Character
To insert characters that are illegal in a string, use an escape character.
An...
PHP Installation
What Do I Need?
To start using PHP, you can:
Find a web host with PHP and MySQL support...
PHP $GLOBALS
$GLOBALS is an array that contains all global variables.
Global Variables
Global...
PHP Continue
The continue statement can be used to jump out of the current iteration of a loop, and...