1

I'm trying to identify my pages (for the menu) using if ternary operator.

$page_name = "workers";

($page_name != "home") ? echo "home";

So I suppose "home" should appear, but no. Parser show me an error:

Parse error: syntax error, unexpected '?'

What I'm doing wrong??

Pedro Lobito
  • 85,689
  • 29
  • 230
  • 253
n21b
  • 33
  • 1
  • 4

1 Answers1

1

You ternary syntax is wrong, try this:

$page_name = "workers";
echo ($page_name != "home" ? "home" : null);
Pedro Lobito
  • 85,689
  • 29
  • 230
  • 253
  • You're very welcome @n21b. If my answer helped you, please give it 1+ and mark it as correct by clicking on the ✓ next to the ▲ ▼ , thank you! – Pedro Lobito May 15 '16 at 02:36