PHP Comment

Last Updated: February 5, 2022

Comments are non-executable text in your PHP code. Comments are added so that humans can easily understand the code.

PHP comments are ignored by the interpreter.

You can have single-line comments and multiline comments in PHP.

PHP single line comments

There are two ways to use single-line comments in PHP.

  • // (C++ style single line comment)
  • # (Unix Shell style single line comment)
// This is a single-line comment
# This is also single-line comment


PHP multiline comments

Comment out multiple lines using /* */


namespace App\Http\Controllers;
use App\Http\Resources\ExpenseResource;
use App\Models\Expense;
use App\Models\ExpenseCategory;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Validator;
use DB; */