Help with Escape Sequences

Hey, am having trouble with the escape sequence with this line of code.

[php]echo “<li class=”<?php echo $current_page == ‘$line.php’ ? ‘active’:NULL ?"">">"$line"";

and I tried this

“<li class=”"<?php echo $current_page == $line.php ? 'active':NULL ?>"">$line"[/php]

Just generally having trouble with this.

		[php]	<?php 
				while (!feof($file_handle)) {
   					$line = fgets($file_handle);
   					echo "<li class=""<?php echo $current_page == $line.php ? 'active':NULL ?>""><a href=$line.php>$line</a></li>";
				}
				fclose($file_handle);
			?>[/php]

The piece looks like this.

Ok, I’ve got it to work but now its missing the html active class.

[php]echo “<li class=”$current_page == ‘signup.php’ ? ‘active’:NULL ?>"><a href="{$line}.php">{$line}";[/php]

The raw html is looking like this.

[php]

  • Index
  • [/php]

    and it should look like this.

    [php]

  • Index
  • [/php]

    You are trying to do too much on a single line. Rather than doing in line ternary statements, have those out of the print statement, and just use their variables inside it.

    [php]
    $current_page == ‘signup.php’ ? ‘active’:NULL;
    echo “

  • {$line}
  • ”;
    [/php]
    Sponsor our Newsletter | Privacy Policy | Terms of Service