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

  • SEARCH
  • Home
  • 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 8431897
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T05:58:42+00:00 2026-06-10T05:58:42+00:00

I have URLs in this format : http://site.com/index.php?title=[SOME_UNICODE_TITLE]&id=[ID]&type=[TYPE] When I try to use htmlspecialchars

  • 0

I have URLs in this format :

http://site.com/index.php?title=%5BSOME_UNICODE_TITLE%5D&id=%5BID%5D&type=%5BTYPE%5D

When I try to use htmlspecialchars on this URL to encode unicode title the function encodes & too; so it will be &amp so variable name id is converted to ampid !
So I can’t read it from code.

How can I use htmlspecialchars on a URL without converting URL specific chars (e.g. &,=,…)?

  • 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-10T05:58:45+00:00Added an answer on June 10, 2026 at 5:58 am

    IMHO you should just use urlencode() for URLs, because that’s what it is made for. If you cannot / do not want to use it and you always get a full URI. You could parse if before encoding it:

    $uriParts = parse_url($fullUri);
    $queryParts = array();
    parse_str($uriParts['query'], $queryParts);
    
    foreach($queryParts as $name => $value) {
        $queryParts[$name] = htmlspecialchars($value);
    
        // don't know whether you want to encode the key too
    }
    

    http://php.net/manual/en/function.parse-str.php
    http://www.php.net/manual/en/function.parse-url.php

    Example: http://codepad.viper-7.com/lIFiHB

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

Sidebar

Related Questions

I need to redirect multiple urls from this format: http://site.com/gallery.php%3Fpage%3D12 (the 12 at the
Currently, I have 20+ URLs on my site in this format http://www.example.net/content/index/mission I want
Im sure this is simple but newbie here. I have 5 URLS cards.php&type=one cards.php&type=two
I have a list of URLs such as, http://www.mywebsite.com/page.php?genus=A_GENUS&species=A_SPECIES&id=12345 . I would like to
About the system I have URLs of this format in my project:- http://project_name/browse_by_exam/type/tutor_search/keyword/class/new_search/1/search_exam/0/search_subject/0 Where
I have urls of the following format (I write it as as aregex): http://exampledomain\.com/files/.+
I have a website that has images with urls like this: http://mysite.com/image1.jpg My server
I have thousands of URLs that look like this: http://www.domain.com/here-is-a-product-ab00007a1.html The number at the
I have urls like this: www.wunderwedding.com/weddingvenues/share-weddingvenue/175/beachclub-all-good www.wunderwedding.com/weddingvenues/share-weddingvenue/2567/castle-rock Since these urls no longer exist, I
What I'm trying to do: have pretty URLs in the format ' http://domain.tld/one/two/three ',

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.