reading a variable with #

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
pelegk2
Forum Regular
Posts: 633
Joined: Thu Nov 27, 2003 5:02 am
Location: Israel - the best place to live in after heaven
Contact:

reading a variable with #

Post by pelegk2 »

i have page that recives avalue :

Code: Select all

<?php
1.php?file=123#asw1

?>
when i try to read this file variable i recive :

Code: Select all

$_REQUEST&#1111;'file'] == '123#'

 instead of :
$_REQUEST&#1111;'file'] == '123#asw1'
why is that?
thnaks in advance
peleg
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

stuff after the # in a url is called a hash, it's used by the browser to change the focus to a named anchor inside the requested page. The server doesn't need to know it, and often doesn't.
Illusionist
Forum Regular
Posts: 903
Joined: Mon Jan 12, 2004 9:32 pm

Post by Illusionist »

try to [php_man]urlencode()[/php_man] the url if you can
User avatar
pelegk2
Forum Regular
Posts: 633
Joined: Thu Nov 27, 2003 5:02 am
Location: Israel - the best place to live in after heaven
Contact:

feyd i know

Post by pelegk2 »

feyd i know that the # in an anchor tag butii talk about server side not client!!!!
why should it interest the server that u have an anchor?
it shouldnt!!!!
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

someone woke up cranky.. :roll: :?
d3ad1ysp0rk
Forum Donator
Posts: 1661
Joined: Mon Oct 20, 2003 8:31 pm
Location: Maine, USA

Re: feyd i know

Post by d3ad1ysp0rk »

pelegk2 wrote:feyd i know that the # in an anchor tag butii talk about server side not client!!!!
why should it interest the server that u have an anchor?
it shouldnt!!!!
yes, it should. Whenever the server sees # in a URL, it's assuming the url looks like:
page.php#name
where name is the <a name> you'd like to start viewing the page at.

Sure, it'd be nice if the server ignored # signs that came after the =, but it doesnt, the same way it doesnt ignore & signs if you'd like to make them part of a variable (page.php?x=3sja&fdk&y=783rbdf won't read correctly, it'd most likely set a variable called fdk with no value, and then x=3sja..
User avatar
pelegk2
Forum Regular
Posts: 633
Joined: Thu Nov 27, 2003 5:02 am
Location: Israel - the best place to live in after heaven
Contact:

Post by pelegk2 »

so why it dosent do problem when i have :
file=dsfadsf=123
and gives me :
dsfadsf=123
and not just

dsfadsf
d3ad1ysp0rk
Forum Donator
Posts: 1661
Joined: Mon Oct 20, 2003 8:31 pm
Location: Maine, USA

Post by d3ad1ysp0rk »

because there is no & in there, so i'd expect it to read the whole thing.
Post Reply