简体   繁体   中英

PHP echoing '<<<'

I want to echo some HTML from PHP that contains a link that has the text '<<< Back' on it. I can't get the '<<<' to display properly.

Anybody have any ideas? This is my current code:

  $paginationDisplay .=  '&nbsp; <span class="paginationNumbersbn"> <a href="' . $_SERVER['PHP_SELF'] . '?pn=' . $previous . '"> '<<<'Back</a></span> ';

If you want to display a literal less-than sign, encode it as &lt; as per the HTML spec.

You might also want to look into another related entity: &laquo; . This produces a double left angle quote:

«

You don't need to escape it, as it has nothing to do with PHP.

Often websites just print out <, instead of using the appropriate HTML entity.

Try the following:

  $paginationDisplay .=  '&nbsp; <span class="paginationNumbersbn"> <a href="' . $_SERVER['PHP_SELF'] . '?pn=' . $previous . '"> &lt;&lt;&lt;Back</a></span> ';
$paginationDisplay .= '&nbsp; <span class="paginationNumbersbn"> <a href="' . $_SERVER['PHP_SELF'] . '?pn=' . $previous . '">&lt;&lt;&lt;Back</a></span>';

&lt; = < &gt; = >

You can use these and many other HTML entities to put symbols like this into your page.

It doesn't work properly because PHP attaches a special meaning to <<< called HEREDOC. You are better off encoding each < as &lt; and then displaying it as the others suggested.

http://www.php.net/manual/en/language.types.string.php#language.types.string.syntax.heredoc

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM