0

link is : info.php?Submit=#img.png

so

<?php echo $_GET["Submit"]; ?>

but this wil show : #img.png how to remove the "#" from the name so it shows : img.png ??

thanks

1

3 Answers 3

4

$_GET["Submit"] will not contain that, since # marks the beginning of the 'fragment', which does not get passed to the server.

If the link is info.php?Submit=%23img.png, then you can trim it like this:

<?php echo substr($_GET["Submit"], 1); ?>
Sign up to request clarification or add additional context in comments.

Comments

2

Well, you could always modify the sender code to exclude the leading # (or %23 as @Cal pointed out).

Otherwise, try one of these:

//substring [1:len]
$yourString = substr($_GET["Submit"], 1);

//replace "#" with ""
$yourString = str_replace("%23", "", $_GET["Submit"], 1); //1 is the limit of #s to remove

//parse the URL, then get the path
$yourString = parse_url($_GET["Submit"], PHP_URL_PATH);

1 Comment

i get this error : Fatal error: Only variables can be passed by reference in demo.php on line 6
0

Try this, if you are sure that the first character is either a # or the encoding of one (%23):

<?php echo substr(urldecode($_GET["Submit"]),1); ?>

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.