Skip to content
Learn Netverks

Lesson

Step 8/36 22% through track

operators

Operators and expressions

Last reviewed May 28, 2026 Content v20260528
Track mode
server_script
Means
Server runner
Reading
~1 min
Level
beginner

This lesson

This lesson teaches Operators and expressions: the syntax, APIs, and habits you need before advancing in PHP.

Teams ship Operators and expressions on every PHP codebase—skipping it leaves gaps in debugging and code reviews.

You will apply Operators and expressions in contexts like: LAMP/LEMP stacks, Laravel apps, WordPress themes/plugins, and shared hosting.

Write PHP in the editor and click Run on server—the dev runner executes your script and returns stdout/stderr (set LEARNING_RUNNER_ENABLED=true locally).

When you can explain the previous lesson's ideas without copying starter code.

PHP supports arithmetic, comparison, logical, string concatenation, and assignment operators familiar from JavaScript—with a few PHP-specific surprises around type juggling.

Common operators

  • Arithmetic: + - * / % **
  • Concatenation: .'Hello, ' . $name
  • Comparison: === !== == != < > <= >=
  • Logical: && || ! and word forms and or xor (lower precedence—avoid in new code)
  • Null coalescing: ??$x ?? 'default'
  • Nullsafe (PHP 8+): ?-> on objects

Increment and compound assignment

$n = 1;
$n += 2;   // 3
$n++;      // post-increment

Type juggling trap

var_dump(0 == 'foo');  // true (legacy quirk)
var_dump(0 === 'foo'); // false

Use strict comparison and explicit casting in production code.

Self-check

  1. Which operator concatenates strings?
  2. What does $value ?? 'none' return when $value is undefined?

Interview tip Lesson completion confidence

Can you explain this lesson in 30 seconds without reading notes?

Not saved yet.

Playground

Runs on the configured server runner (dev: npm run runner with LEARNING_RUNNER_ENABLED=true). Output appears below the editor.

Check yourself

Multiple choice — immediate feedback.

Discussion

Past discussion is visible to everyone. Only logged-in users can post comments and replies.

Starter discussion topics

  • === vs == example?
  • Null coalesce use?

Sign up or log in to post comments and sync lesson progress across devices.

No discussion yet. Be the first to ask a question.

Jump