php - Notice: Undefined variable: x in include() -


i used ternary operators have multiple backgrounds listed item.

but getting error, error message

notice: undefined variable: x in include() (line 45 of /home/content/67/11380467/html/beta/sites/all/modules/custom/blogs.tpl.php).

<?php       $x++;        $class = ($x%2 == 0)? 'second': '';     print $class;   ?> 

can please me understand went wrong here , me fix it.

thanks!

$x undefined. can't $x++ when didn't define yet. need add in front:

$x = 0; 

this assuming want start @ 0


Comments