$ and $$ — PHP Technical Interview Questions & Answers

$ and $$

$ and $$

  • $ and $$ is a PHP topic. In plain words you use it for $marks = 72 in a result script. Don’t start with a slogan — start with that picture.
  • Smallest example: $name = 'Asha';. Type it, run it, and say what you see. If you can do that from memory, you know $ and $$.
  • From the example next to this theory: $ and $$: scores array, print avg, then high marks.
  • Trap: using marks without $. Fix that before you talk about advanced PHP.
  • Viva: what is $ and $$? Then show $name = 'Asha';. Then name the trap.

Technical Interview Tip: What is $ and $$? Show this: $name = 'Asha';. Trap: using marks without $.

Code Examples for $ and $$

$ and $$ — working example

<?php
// $ and $$
$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";
}

$ and $$: scores array, print avg, then high marks. Say the output.

How to Explain $ and $$ to an Interviewer

What is $ and $$?

Used for $marks = 72 a result script Not just the heading

Give one small example of $ and $$.

$name = 'Asha'; $ and $$: scores array, print avg, then high marks

What mistake do beginners make with $ and $$?

using marks without $ Show the fix

Where do you use $ and $$?

a result script $marks = 72