calastinone
calastinone

Reputation: 11

how do you echo the following special characters using PHP and make the browser display these:

Help I am stuck with the following Problem and i cant figure this out. I am supposed to do the following in PHP:

Set a variable to the following: “<&¢£¥€©>” and output it as shown to the browser window.

Here is my code: <?php $str = "&lt;&amp;&cent;&pound;&yen;&euro;&copy;&gt;" echo htmlspecialchars($str); ?>

but i keep getting an error.

Upvotes: 0

Views: 97

Answers (2)

invisal
invisal

Reputation: 11171

Do you mean you want to do something like this?

$str = "<&¢£¥€©>";
echo htmlspecialchars($str);

Upvotes: 1

Yolo
Yolo

Reputation: 1579

Missing semicolon

$str = "&lt;&amp;&cent;&pound;&yen;&euro;&copy;&gt;"; // <-- missing semicolon
echo htmlspecialchars($str);

Upvotes: 1

Related Questions