Board index   FAQ   Search  
Register  Login
Board index php forum :: php coding PHP coding => General

URL variables

Ask about general coding issues or problems here.

Moderators: macek, egami, gesf

URL variables

Postby shufty » Sat Aug 17, 2002 5:56 am

i am new to PHP totally. All i can do is includes. :cry:

what i would like to be able to do is declare a set of variables that have URLs as their values. then use the $HTTP_GET_VARS: thing to get the page and have it display it.

the variables i have no idea how to do but i think i know how to do the get:

Code: Select all
$HTTP_GET_VARS['$variable']


am i right?

could someone show me how this works? thanks
shufty
New php-forum User
New php-forum User
 
Posts: 6
Joined: Sat Aug 17, 2002 5:45 am

Postby Jay » Sat Aug 17, 2002 11:11 am

To use variables as part of a url you just make up the URL in the following format:
page.php?var1=value1&var2=value2
You might also want to have a look at the urlencode() function too!

On the page accessed using these variables, you can use a multitude of methods.
If the register_globals setting is ON (set to off in PHP 4.2.0 and later by default), you can just call $var1 and $var2.
Otherwise you can use $HTTP_GET_VARS['var1'] and $HTTP_GET_VARS['var2'].
In PHP 4.1.0 and later they've introduced Super Global Arrays, so you can access them by $_GET['var1'] and $_GET['var2']. As these arrays are Super Global, there's no need to declare them as global in functions!

BTW, you're not the same shufty as on a popular DVD forum, are you? :wink:
Jay
 

Postby shufty » Sat Aug 17, 2002 1:03 pm

no im not im afraid.

so how would i declare a load of variables then. like this
Code: Select all
$HTTP_GET_VARS['$var, $var2, $var3.....']

this
Code: Select all
$_GET['$var, $var2, $var3.....']
or this
Code: Select all
$var=./page/page/page.php, $var2=./page/........., $var3=./page/..........


what i am try to achieve is this

http://site.com/page.php?load=a/new/page.php

am i close with that?
shufty
New php-forum User
New php-forum User
 
Posts: 6
Joined: Sat Aug 17, 2002 5:45 am

Postby Jay » Sun Aug 18, 2002 1:27 am

shufty wrote:no im not im afraid.

so how would i declare a load of variables then. like this
Code: Select all
$HTTP_GET_VARS['$var, $var2, $var3.....']

this
Code: Select all
$_GET['$var, $var2, $var3.....']
or this
Code: Select all
$var=./page/page/page.php, $var2=./page/........., $var3=./page/..........


what i am try to achieve is this

http://site.com/page.php?load=a/new/page.php

am i close with that?

What do you mean by declare? PHP isn't like Perl where you have to declare a variable, you can just use it!

To access the variables on the page generated from the 'GET' variables, just use $_GET['varname'] to access the value. All the GET, POST, SESSION, COOKIE and SERVER variables are posted within their own Super Global Arrays accessed by the method $_ARRAYNAME['varName']

Once you've made up your URL as you've written it, on the next page you can use $_GET['load'] which would give you the value "a/new/page.php"
Jay
 

Postby shufty » Sun Aug 18, 2002 11:06 am

sorry, i'm lost now.

could you show me how i would assign the values to the variables and then structure the URL.

thanks :cry:
shufty
New php-forum User
New php-forum User
 
Posts: 6
Joined: Sat Aug 17, 2002 5:45 am

Postby Jay » Sun Aug 18, 2002 12:09 pm

shufty wrote:sorry, i'm lost now.

could you show me how i would assign the values to the variables and then structure the URL.

thanks :cry:

I already have, in as simple english I could possibly make it. Re-read the thread again!
Jay
 


Return to PHP coding => General

Who is online

Users browsing this forum: Google [Bot] and 4 guests

Sponsored by Sitebuilder Web hosting and Traduzioni Italiano Rumeno and antispam for cPanel.

cron