-4

I don't understand, where the mistake is in this line of code.

$Header .= "<a href='#' onclick='ToggleView(\"Thumbnail\");return false;' title='Grid'><div class='" . 
if ($Starting_Layout = 'Thumbnail'){ echo 'active';} . " thumb-toggle-icon'></div></a>";

Can someone help me fix it?

Rohit Gupta
  • 4,022
  • 20
  • 31
  • 41
Tesla
  • 67
  • 7
  • 2
    What is your error message? I could see 2-3 possible errors. 1. `if` in assignment. 2. `$Starting_Layout` is being set, not compared. 3. `$Header` not initialized. – chris85 Sep 21 '15 at 02:50
  • See also: [Parse/Syntax errors: Unexpected T_IF](http://stackoverflow.com/questions/18050071/php-parse-syntax-errors-and-how-to-solve-them/18092318#18092318). – mario Sep 21 '15 at 03:01
  • It's the `if ($Starting_Layout = 'Thumbnail'){ echo 'active';}` . Replace this with using short-if: `echo ($Starting_Layout = 'Thumbnail' ? "active" : "")` – JM R. Sep 21 '15 at 03:32
  • Thank you! Learn and learn. – Tesla Sep 21 '15 at 19:00

1 Answers1

1

An if statement halfway through your output string? That doesn't look suspicious to you?

John3136
  • 28,809
  • 4
  • 51
  • 69