Bruce
Bruce

Reputation: 119

php7: echo "&amp" returns & versus &amp

<?php
echo "&amp";
?>

result: &

How do I get php to return &amp versus &?

I am attempting to update AMP content. The standard what of posting variables is to append them with an ampersand. The AMP arguments include amp_action, amp_ts and amp_url_signature. PHP is removing the amp following the &, so I cannot perform the update.

Some other examples:

<?php
echo "&"."amp_ts";
?>

result: &_ts

<?php
echo "&". "\amp";
?>

result: &\amp

<?php
echo "&\\"."amp";
?>

result: &\amp

Upvotes: 0

Views: 218

Answers (3)

Johannes
Johannes

Reputation: 67778

It should be echo "&amp;"; just get the ampersand alone ("&") and echo "&amp;amp"; to get "&amp" - note the use of the semicolons

Upvotes: 3

ferrysyahrinal
ferrysyahrinal

Reputation: 64

try this....

echo "&amp;";

Upvotes: 1

nandal
nandal

Reputation: 2634

you can use:-

echo "&ampamp";

Upvotes: 1

Related Questions