PHP Basics

Back to index

1. echo and print

This line is written with echo.

This line is written with print.

2. Variables

Name: Asif

Course: INFOST 440

Year: 2026

Price: 4.75

Is a student: Yes

3. Concatenation

Hello, Asif!

Welcome to INFOST 440

4. Operators

Arithmetic (a = 12, b = 5)

a + b = 17

a - b = 7

a * b = 60

a / b = 2.4

a % b = 2

Assignment: 10, then += 5, then *= 2 gives 30

Comparison

a > b: true

a == b: false

a != b: true

Logical

(a > 10) && (b < 10): true

(a < 10) || (b < 10): true

Increment/decrement: start at 1, ++, ++, -- gives 2

5. Comments

This script uses single-line comments (// and #) and a multi-line comment (/* */). They are only visible in the source code, not in the browser.