Page 1 of 2
How to extract Data from URL bar
Posted: Mon Jun 28, 2004 12:00 pm
by NewfieBilko
Is there anyway to call apon the browser to check the address text in the URL bar? Have it passed to the php?
Posted: Mon Jun 28, 2004 12:26 pm
by markl999
Do a var_dump($_SERVER); You should see all the 'bits' you want in there.
Posted: Wed Jun 30, 2004 11:59 am
by NewfieBilko
I dont think I understand. Just put that function into a PHP file and it will onload all the bits of information, even the address bar url in the output?
Posted: Wed Jun 30, 2004 12:04 pm
by markl999
No, i mean the address in the address bar is made up of a few bits, eg
$_SERVER['HTTP_HOST'], $_SERVER['PHP_SELF'], $_SERVER['REQUEST_URI'] etc...
if you do a var_dump($_SERVER); it will show you all the information it has, and the info you want is in there, so just pick out the bits you want, eg if the url is index.php?foo=bar then you might just want the index.php bit without the ?foo=bar bit ... just depends on your needs. But $_SERVER has it all
Posted: Wed Jun 30, 2004 12:44 pm
by NewfieBilko
ahhh ok nice, so i can do that, var_dump($SERVER) and will get all info.... thats right, but i want to get the file name, no extensions or anything. If i just want the Filename I will:
???????
those 3 additional arrays, they reference the different parts of the url?
Posted: Wed Jun 30, 2004 1:03 pm
by NewfieBilko
BTW, how do i just call apon
var_dump($_SERVER['REQUEST_URI'])
to display OUTput to an html?
Do i put it into my php and then call the function var_dump?
I am running smarty with PHP application background and Templates for my Presentation layer. Should i put var_dump($_SERVER['REQUEST_URI'])
in the template or the application.. Im guessing the application, then how do I display the "bits"?
Posted: Wed Jun 30, 2004 1:08 pm
by patrikG
read the manual and the previous posts. Second link below.
Posted: Wed Jun 30, 2004 1:22 pm
by NewfieBilko
yea that was a bit of a stupid question lol sorry
Posted: Wed Jun 30, 2004 1:22 pm
by NewfieBilko
hahah ever get mind blocked? then you go outside, or have some sex, or smoke a joint, or have a ciggerette, then it all comes back? lol, yea i came back and im like duhhh obvilsouyy make it a varible to display lol
Posted: Wed Jun 30, 2004 1:26 pm
by markl999
Pick which one you want:
Code: Select all
echo $_SERVER['PHP_SELF'];
echo basename($_SERVER['PHP_SELF']);
echo $_SERVER['REQUEST_URI'];
echo __FILE__;
Posted: Wed Jun 30, 2004 1:39 pm
by NewfieBilko
neat.
I am going to try and use this, so that I can dynamically pull in what page it is the enduser is viewing, so that I can then have a TREE, or ROOT structure which will be like HOME -> ADMIN-> USERS-> "CURRENT PAGE", calling in the current page as what it is they are on, then based on which page it is just fill in the rooting links...
Posted: Wed Jun 30, 2004 1:47 pm
by NewfieBilko
hmmm, i need to make
echo basename($_SERVER['PHP_SELF']);
into a variable so I could use it then.
$mark == basename($_SERVER['PHP_SELF']);
???????? then call mark from the presentation or what not?
Posted: Wed Jun 30, 2004 1:53 pm
by NewfieBilko
i've tried:
Code: Select all
$smarty->assign('basename($_SERVER['PHP_SELF'])',$mark);
and then echoing it by refering to it in my html output:
{echo $smarty[mark]} and everything that looks like this but no go.. its ok, ill figure it out im sure lol
Posted: Wed Jun 30, 2004 2:01 pm
by markl999
*smack*
'basename($_SERVER['PHP_SELF'])' remove those outer single quotes, and i'm not sure that's the correct syntax to assign a smarty var, better double check at
http://smarty.php.net
Posted: Wed Jun 30, 2004 2:06 pm
by NewfieBilko
LOL good idea
