Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8676939
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T20:19:30+00:00 2026-06-12T20:19:30+00:00

I asked a question in an another forum related to urlencode(), when a guy

  • 0

I asked a question in an another forum related to urlencode(), when a guy appeared saying briskly it is absolutly required to make use of htmlentities on top of it, and also suggesting I should do that everytime I write an URL. “To be valid and secure he said”. I do not see why it could be a security issue. Here is the code he mentionned :

echo '<a href="index.php?' . htmlentities('page=encode&code='.urlencode($code).'&login='.urlencode($login).'&codeconf=' . urlencode($codeconf)) . '">';

Php Manual indeed mentions htmlentities. But there are no further explanations:

Note … PHP supports changing the argument separator to the W3C-suggested semi-colon through the arg_separator .ini directive. Unfortunately most user agents do not send form data in this semi-colon separated format. A more portable way around this is to use & instead of & as the separator. You don’t need to change PHP’s arg_separator for this. Leave it as &, but simply encode your URLs using htmlentities() or htmlspecialchars().

I replaced “&” by &amp ; , I validated my page in W3C validator and it came out OK.

I am still concerned about this htmlentities issue.

  1. Is there any good reason why whe should use htmlentities in URL’s ?
  2. If yes, does this apply to all types of URL’s ?
  3. If yes, is it for security reasons ?
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T20:19:31+00:00Added an answer on June 12, 2026 at 8:19 pm

    This is not about HTML entities in URLs. This is about you putting arbitrary data into HTML, which means you need to HTML escape any special characters in it. That this data happens to be a URL is irrelevant.

    1. You need to escape any arbitrary data you put into the URL with urlencode to preserve characters with a special meaning in the URL.
    2. The arbitrary blob of data you get from step one needs to be HTML escaped for the same reasons when put into HTML. As you see in your example, there’s an & in your data which is required to be escaped to &amp; by HTML rules.

    If you did not use the URL in an HTML context, there’d be no need to HTML escape it. HTML entities have no place in a URL. A URL in an HTML context must be HTML escaped though, like any other data.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This question is related to another question I asked Basically, I have 2 horizontally
I asked another SOAP related question some time ago, which asks for a working
This is a question I asked on another forum which received some decent answers,
In another unrelated Internet forum a question was asked on how to check if
This is related to another question that I had asked Is fb:multi-friend-selector deprecated? .
I asked this question in another post - How do I put a <div>
Yesterday I asked another question to calculate time. Now I realized, that it makes
In another question I asked (why is Rake test so slow ), part of
In another question , I asked something similar but I ended up just posting
I asked this question earlier. I am intrigued by std::set but I have another

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.