Pass a percent (%) sign in a url and get exact value of it using php












24














I am trying to pass percent (%) sign in url like



%B6011000995504101^SB


but when I echo, it returns



♦011000995504101^SB


I want exact same value as I pass it in URL.



I have tried to use urlencode() function, but it give me output like this...



%B6011000995504101%5ESB


please help me regarding this










share|improve this question


















  • 2




    use url_encode() and url_decode() may also require htmlentities() %B6 for example is the code for the blob you got. passing the % is actually a really bad idea you'd be better off passing a different character for percent or not passing it at all and assume that the % is always there and assign it i nyour script after.
    – Dave
    Jun 27 '13 at 12:06












  • % is used for urlencode, better to pass a specific pattern like $$ or something else and decode it in the php code.
    – Sudip Pal
    Jun 27 '13 at 12:07










  • possible duplicate of urlencode but ignore certain chars
    – Simon M
    Jun 27 '13 at 12:08
















24














I am trying to pass percent (%) sign in url like



%B6011000995504101^SB


but when I echo, it returns



♦011000995504101^SB


I want exact same value as I pass it in URL.



I have tried to use urlencode() function, but it give me output like this...



%B6011000995504101%5ESB


please help me regarding this










share|improve this question


















  • 2




    use url_encode() and url_decode() may also require htmlentities() %B6 for example is the code for the blob you got. passing the % is actually a really bad idea you'd be better off passing a different character for percent or not passing it at all and assume that the % is always there and assign it i nyour script after.
    – Dave
    Jun 27 '13 at 12:06












  • % is used for urlencode, better to pass a specific pattern like $$ or something else and decode it in the php code.
    – Sudip Pal
    Jun 27 '13 at 12:07










  • possible duplicate of urlencode but ignore certain chars
    – Simon M
    Jun 27 '13 at 12:08














24












24








24


4





I am trying to pass percent (%) sign in url like



%B6011000995504101^SB


but when I echo, it returns



♦011000995504101^SB


I want exact same value as I pass it in URL.



I have tried to use urlencode() function, but it give me output like this...



%B6011000995504101%5ESB


please help me regarding this










share|improve this question













I am trying to pass percent (%) sign in url like



%B6011000995504101^SB


but when I echo, it returns



♦011000995504101^SB


I want exact same value as I pass it in URL.



I have tried to use urlencode() function, but it give me output like this...



%B6011000995504101%5ESB


please help me regarding this







php urlencode






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Jun 27 '13 at 12:04









Sumit BijvaniSumit Bijvani

5,995163975




5,995163975








  • 2




    use url_encode() and url_decode() may also require htmlentities() %B6 for example is the code for the blob you got. passing the % is actually a really bad idea you'd be better off passing a different character for percent or not passing it at all and assume that the % is always there and assign it i nyour script after.
    – Dave
    Jun 27 '13 at 12:06












  • % is used for urlencode, better to pass a specific pattern like $$ or something else and decode it in the php code.
    – Sudip Pal
    Jun 27 '13 at 12:07










  • possible duplicate of urlencode but ignore certain chars
    – Simon M
    Jun 27 '13 at 12:08














  • 2




    use url_encode() and url_decode() may also require htmlentities() %B6 for example is the code for the blob you got. passing the % is actually a really bad idea you'd be better off passing a different character for percent or not passing it at all and assume that the % is always there and assign it i nyour script after.
    – Dave
    Jun 27 '13 at 12:06












  • % is used for urlencode, better to pass a specific pattern like $$ or something else and decode it in the php code.
    – Sudip Pal
    Jun 27 '13 at 12:07










  • possible duplicate of urlencode but ignore certain chars
    – Simon M
    Jun 27 '13 at 12:08








2




2




use url_encode() and url_decode() may also require htmlentities() %B6 for example is the code for the blob you got. passing the % is actually a really bad idea you'd be better off passing a different character for percent or not passing it at all and assume that the % is always there and assign it i nyour script after.
– Dave
Jun 27 '13 at 12:06






use url_encode() and url_decode() may also require htmlentities() %B6 for example is the code for the blob you got. passing the % is actually a really bad idea you'd be better off passing a different character for percent or not passing it at all and assume that the % is always there and assign it i nyour script after.
– Dave
Jun 27 '13 at 12:06














% is used for urlencode, better to pass a specific pattern like $$ or something else and decode it in the php code.
– Sudip Pal
Jun 27 '13 at 12:07




% is used for urlencode, better to pass a specific pattern like $$ or something else and decode it in the php code.
– Sudip Pal
Jun 27 '13 at 12:07












possible duplicate of urlencode but ignore certain chars
– Simon M
Jun 27 '13 at 12:08




possible duplicate of urlencode but ignore certain chars
– Simon M
Jun 27 '13 at 12:08












2 Answers
2






active

oldest

votes


















53














Answer:



To send a % sign in a url, instead send %25.



In your case, in order for php to see a percent sign, you must pass the character string %25B6011000995504101^SB to the server.



Why:



In URLs, the percent sign has special meaning. Is used to encode special characters. For example, & is the separator between parameters, so if you want your parameter to actually contain an &, you instead write %26. Because the percent sign is used to encode special characters, it is also a special character, and so if you want to actually send a percent sign, it must also be encoded. The encoding for a percent sign is %25.






share|improve this answer























  • it adds another 25 like %2525
    – Anonymous
    Mar 8 '18 at 13:20










  • Awesome!! I was beating myself up because of this problem... thx
    – Paulo Künzel
    Dec 12 '18 at 21:38



















3














Before including a raw string in a URL it's a good idea to pass it through urlencode like so:



<?php
$original='%B6011000995504101^SB';

$updated=urlencode($original);

echo "<a href="some_page.php?$updated">Link here</a>";
?>


The receiving page will know what to do - give this example a try on your webserver:



<?php

if($_GET['argument']) {
echo "<p>You passed in the argument &quot;$_GET[argument]&quot;</p>";
}else {
echo "<p>No argument was passed.</p>";
}
$original='%B6011000995504101^SB';

$updated=urlencode($original);

echo "<a href="urlencode.php?argument=$updated">Link here</a>";
?>


(name the file urlencode.php)






share|improve this answer





















  • I have already tried it..
    – Sumit Bijvani
    Jun 27 '13 at 12:11











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f17342671%2fpass-a-percent-sign-in-a-url-and-get-exact-value-of-it-using-php%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























2 Answers
2






active

oldest

votes








2 Answers
2






active

oldest

votes









active

oldest

votes






active

oldest

votes









53














Answer:



To send a % sign in a url, instead send %25.



In your case, in order for php to see a percent sign, you must pass the character string %25B6011000995504101^SB to the server.



Why:



In URLs, the percent sign has special meaning. Is used to encode special characters. For example, & is the separator between parameters, so if you want your parameter to actually contain an &, you instead write %26. Because the percent sign is used to encode special characters, it is also a special character, and so if you want to actually send a percent sign, it must also be encoded. The encoding for a percent sign is %25.






share|improve this answer























  • it adds another 25 like %2525
    – Anonymous
    Mar 8 '18 at 13:20










  • Awesome!! I was beating myself up because of this problem... thx
    – Paulo Künzel
    Dec 12 '18 at 21:38
















53














Answer:



To send a % sign in a url, instead send %25.



In your case, in order for php to see a percent sign, you must pass the character string %25B6011000995504101^SB to the server.



Why:



In URLs, the percent sign has special meaning. Is used to encode special characters. For example, & is the separator between parameters, so if you want your parameter to actually contain an &, you instead write %26. Because the percent sign is used to encode special characters, it is also a special character, and so if you want to actually send a percent sign, it must also be encoded. The encoding for a percent sign is %25.






share|improve this answer























  • it adds another 25 like %2525
    – Anonymous
    Mar 8 '18 at 13:20










  • Awesome!! I was beating myself up because of this problem... thx
    – Paulo Künzel
    Dec 12 '18 at 21:38














53












53








53






Answer:



To send a % sign in a url, instead send %25.



In your case, in order for php to see a percent sign, you must pass the character string %25B6011000995504101^SB to the server.



Why:



In URLs, the percent sign has special meaning. Is used to encode special characters. For example, & is the separator between parameters, so if you want your parameter to actually contain an &, you instead write %26. Because the percent sign is used to encode special characters, it is also a special character, and so if you want to actually send a percent sign, it must also be encoded. The encoding for a percent sign is %25.






share|improve this answer














Answer:



To send a % sign in a url, instead send %25.



In your case, in order for php to see a percent sign, you must pass the character string %25B6011000995504101^SB to the server.



Why:



In URLs, the percent sign has special meaning. Is used to encode special characters. For example, & is the separator between parameters, so if you want your parameter to actually contain an &, you instead write %26. Because the percent sign is used to encode special characters, it is also a special character, and so if you want to actually send a percent sign, it must also be encoded. The encoding for a percent sign is %25.







share|improve this answer














share|improve this answer



share|improve this answer








edited Jan 13 '17 at 3:17

























answered Jun 27 '13 at 12:09









IanPudneyIanPudney

4,73211630




4,73211630












  • it adds another 25 like %2525
    – Anonymous
    Mar 8 '18 at 13:20










  • Awesome!! I was beating myself up because of this problem... thx
    – Paulo Künzel
    Dec 12 '18 at 21:38


















  • it adds another 25 like %2525
    – Anonymous
    Mar 8 '18 at 13:20










  • Awesome!! I was beating myself up because of this problem... thx
    – Paulo Künzel
    Dec 12 '18 at 21:38
















it adds another 25 like %2525
– Anonymous
Mar 8 '18 at 13:20




it adds another 25 like %2525
– Anonymous
Mar 8 '18 at 13:20












Awesome!! I was beating myself up because of this problem... thx
– Paulo Künzel
Dec 12 '18 at 21:38




Awesome!! I was beating myself up because of this problem... thx
– Paulo Künzel
Dec 12 '18 at 21:38













3














Before including a raw string in a URL it's a good idea to pass it through urlencode like so:



<?php
$original='%B6011000995504101^SB';

$updated=urlencode($original);

echo "<a href="some_page.php?$updated">Link here</a>";
?>


The receiving page will know what to do - give this example a try on your webserver:



<?php

if($_GET['argument']) {
echo "<p>You passed in the argument &quot;$_GET[argument]&quot;</p>";
}else {
echo "<p>No argument was passed.</p>";
}
$original='%B6011000995504101^SB';

$updated=urlencode($original);

echo "<a href="urlencode.php?argument=$updated">Link here</a>";
?>


(name the file urlencode.php)






share|improve this answer





















  • I have already tried it..
    – Sumit Bijvani
    Jun 27 '13 at 12:11
















3














Before including a raw string in a URL it's a good idea to pass it through urlencode like so:



<?php
$original='%B6011000995504101^SB';

$updated=urlencode($original);

echo "<a href="some_page.php?$updated">Link here</a>";
?>


The receiving page will know what to do - give this example a try on your webserver:



<?php

if($_GET['argument']) {
echo "<p>You passed in the argument &quot;$_GET[argument]&quot;</p>";
}else {
echo "<p>No argument was passed.</p>";
}
$original='%B6011000995504101^SB';

$updated=urlencode($original);

echo "<a href="urlencode.php?argument=$updated">Link here</a>";
?>


(name the file urlencode.php)






share|improve this answer





















  • I have already tried it..
    – Sumit Bijvani
    Jun 27 '13 at 12:11














3












3








3






Before including a raw string in a URL it's a good idea to pass it through urlencode like so:



<?php
$original='%B6011000995504101^SB';

$updated=urlencode($original);

echo "<a href="some_page.php?$updated">Link here</a>";
?>


The receiving page will know what to do - give this example a try on your webserver:



<?php

if($_GET['argument']) {
echo "<p>You passed in the argument &quot;$_GET[argument]&quot;</p>";
}else {
echo "<p>No argument was passed.</p>";
}
$original='%B6011000995504101^SB';

$updated=urlencode($original);

echo "<a href="urlencode.php?argument=$updated">Link here</a>";
?>


(name the file urlencode.php)






share|improve this answer












Before including a raw string in a URL it's a good idea to pass it through urlencode like so:



<?php
$original='%B6011000995504101^SB';

$updated=urlencode($original);

echo "<a href="some_page.php?$updated">Link here</a>";
?>


The receiving page will know what to do - give this example a try on your webserver:



<?php

if($_GET['argument']) {
echo "<p>You passed in the argument &quot;$_GET[argument]&quot;</p>";
}else {
echo "<p>No argument was passed.</p>";
}
$original='%B6011000995504101^SB';

$updated=urlencode($original);

echo "<a href="urlencode.php?argument=$updated">Link here</a>";
?>


(name the file urlencode.php)







share|improve this answer












share|improve this answer



share|improve this answer










answered Jun 27 '13 at 12:10









Nate from KalamazooNate from Kalamazoo

38616




38616












  • I have already tried it..
    – Sumit Bijvani
    Jun 27 '13 at 12:11


















  • I have already tried it..
    – Sumit Bijvani
    Jun 27 '13 at 12:11
















I have already tried it..
– Sumit Bijvani
Jun 27 '13 at 12:11




I have already tried it..
– Sumit Bijvani
Jun 27 '13 at 12:11


















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f17342671%2fpass-a-percent-sign-in-a-url-and-get-exact-value-of-it-using-php%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Xamarin.iOS Cant Deploy on Iphone

Glorious Revolution

Dulmage-Mendelsohn matrix decomposition in Python