Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Comments in PHP | First Acquaintance
Introduction to PHP
course content

Зміст курсу

Introduction to PHP

Introduction to PHP

1. First Acquaintance
2. Variables and Data Types
3. Conditional Statements
4. Arrays
5. Loops

Comments in PHP

Usage of Comments


Developers often need tools to make their code easier to understand, both for themselves and for the people they work with. Comments are one such tool, as they allow us to explain parts of the code. The PHP interpreter ignores comments, so they don't affect the execution of the program. Comments can be used for:

1. Explaining what the code does:

php

index

The comment above clearly indicates to us what exactly this code does.

2. Commenting out code blocks to avoid errors at runtime:

php

main

The comment above clearly demonstrates that the commented lines of code are ignored and do not affect the code execution result.

Single-Line and Multi-Line Comments


A single-line comment starts with // and continues to the end of the line:

php

main

A multi-line comment starts with /* and ends with */. It can span multiple lines:

php

main

How many times will the word "Hello, World!" be displayed in the console?

Виберіть правильну відповідь

Все було зрозуміло?

Секція 1. Розділ 3
We're sorry to hear that something went wrong. What happened?
some-alt