1

I'm using the following code to piece together a series of variables declared further back in the script to form the link portion of a RSS XML feed. I need to insert a ampersand between the variables to complete the URL properly. I've tried using & and also just & put it ends up with an error:

error on line 7 at column 194: Entity Ref: expecting ';'

Can somebody please show me so I can see what I am doing wrong?

echo '<link>' . $url . 'ampersand_goes_here' . $mlcall. '' . $title . '</link>';
1
  • what am I doing wrong? You're not using something like SimpleXML to generate your XML for you. Commented Nov 17, 2012 at 1:21

2 Answers 2

1

try enclosing the string within the link tag with the htmlspecialchars() function.

echo '<link>' . htmlspecialchars($url . 'ampersand_goes_here' . $mlcall. '' . $title) . '</link>';
Sign up to request clarification or add additional context in comments.

2 Comments

can you show me the proper syntax within the example provided please?
Well you might as well replace 'ampersand_goes_here' by & then. :) This call will indeed transform it into the html entity &amp;
0
echo "<link>$url&amp;$mlcall$title</link>";

or (better yet)

echo '<link>' . htmlentities($url&$mlcall$title) . '</link>';

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.