Skip to content
PHP Logo

How can source code be commented in PHP, besides using /* ... */?

In PHP, besides using the traditional /* ... */ for multi-line comments, you can also use // for single-line comments. This allows you to add comments to individual lines of code without having to wrap them in a block comment. Single-line comments are useful for quickly adding notes or explanations to specific parts of your code.

php
// This is a single-line comment in PHP

echo "Hello, World!"; // This line prints a greeting message