PGoCareerGoCareer prep tools
Home
LoginSign up
  • Java
  • Python
  • AI
  • React
  • Angular
  • PHP
  • Node.js
  • SQL
  • DSA
  • HTML
  • CSS
  • JS
  • Spring
  • ML
  • MongoDB

PHP · Theory

If else

← All stacks

Theory

17/352

If else

If else is simple if you keep it on paper. Asha uses it for If else on Asha's board in a viva board.

Keep If else small. Asha should finish If else on Asha's board in a few lines, not a 40-line dump.

Without If else, a viva board gets messy and If else on Asha's board is hard to trust.

Use If else when If else on Asha's board must stay clear. If a simpler PHP step works, use that instead.

If else trap — only reciting the name of If else. Asha loses marks for that every viva.

Place If else next to nearby PHP work — one If else step Asha can write from memory is the link.

Viva for If else: what it is → one If else step Asha can write from memory → the mistake (only reciting the name of If else).

Exam tip

Board: If else on Asha's board. Dry-run If else. Name the trap: only reciting the name of If else.

Example

<?php
// If else
$scores = [80, 90, 70];
$avg = array_sum($scores) / count($scores);
echo "avg=" . number_format($avg, 1) . "\n";
foreach ($scores as $s) {
  if ($s >= 80) echo "high: $s\n";
}

If else: scores array, print avg, then high marks. Say the output.

Short notes

  • DefIf else — Asha uses it for If else on Asha's board in a viva board.
  • RuleIf else → one If else step Asha can write from memory.
  • RememberIf else + the PHP runtime (a viva board).
  • UseIf else in a viva board (If else on Asha's board).
  • TrapIf else — only reciting the name of If else.
  • ExIf else → If else on Asha's board.

Questions

1

What is If else? Teach it with If else on Asha's board.

2

Name one PHP screen/job that needs If else.

3

Viva: one wrong answer people give for If else.

4

Show If else in the PHP runtime terms — three lines max.

Previous← CommentsNextSwitch →
P

GoCareerGo

Utilities · Preparation Hub · Resume · CV · Tools — one workspace.

Workspace

DashboardProfilePreparation HubResume builderCV builderCareer planning

PDF Tools

Merge PDFSplit PDFCompress PDFImage to PDFAll toolsJobs

Image & QR

Compress ImageResize ImageQR ScannerQR GeneratorBlogIT interview prep

Company

FAQFeedbackContactPrivacyTermsSitemap

© 2026 GoCareerGo. Keep moving forward.