Jump to content

Greater Than/less Than Signs In Php Variables


niche
 Share

Recommended Posts

Please, I want this script:<?php$options = "";$thing = "Sports";$options.="<OPTION>".$thing. "</option>";echo $options;?>to echo: <OPTION>Sports</option>How do I escape the greater than / less than signs? I'm trying to build a drop down menu from a MYSQL table.Thanks

Link to comment
Share on other sites

You encode them as entities, either manually or by using htmlspecialchars().

<?php$options = "";$thing = "Sports";$options.="<OPTION>".$thing. "</option>";echo htmlspecialchars($options);?>

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...