|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
AT&T devCentral & BlackBerry(r) Webcast Series: BlackBerry and GPS -Build Location Awareness into your BlackBerry Applications, July 10th-1:00PM EST. Register Today!
|
|
#1
|
|||
|
|||
|
help with sorta simple code
im trying to find a way to take the current url's query info ( ex: www.page.org?page=news ) and put it in a variable, then include or write from a file named 'news.html' (or whatever the ?page= points to). ive been trying many ways and am currently having headaches because of it
|
|
#2
|
|||
|
|||
|
RE: help with sorta simple code
go with the "parse_url" function to split up your uri, and then go from there
|
|
#3
|
|||
|
|||
|
RE: help with sorta simple code
yeah i used parse_url before... and im not sure if it was right... it looked like this:
$page = parse_url($PHP_SELF) $page = $page[query] so then if the url looked like ?page=home it would theoretically make $page = home, right? anyway then i did $page .= ".html" and include($page) and i dont think that worked... it should right? maybe i should try it again. |
|
#4
|
|||
|
|||
|
RE: help with sorta simple code
me again...
i just tried this code : <? if ($view === false) $view = "home" $view .= ".html" include($view) ?> where the url would be www.page.org?view=home it didnt work, i got "Parse error: parse error, unexpected T_VARIABLE" would this method work, or should i stick with the parse_url. ill get back to you guys after trying parse again... |
|
#5
|
|||
|
|||
|
RE: help with sorta simple code
|
|
#6
|
|||
|
|||
|
RE: help with sorta simple code
|
|
#7
|
|||
|
|||
|
RE: help with sorta simple code
no, see $PHP_SELF won't return your uri variables.. you'll need to use $HTTP_SERVER_VARS[REQUEST_URI]
for example.. $uri = $HTTP_SERVER_VARS["REQUEST_URI"]; parse_url($uri); or if you need the domain too, then use $HTTP_SERVER_VARS["HTTP_HOST"] and hook the two together such as.. $vars = $HTTP_SERVER_VARS["REQUEST_URI"]; $domain = $HTTP_SERVER_VARS["HTTP_HOST"]; $uri = "$vars$domain"; parse_url($uri); err.. you might need the http://full-addy in there for the parse_url to work either way.. hope that helps.. |
|
#8
|
|||
|
|||
|
RE: help with sorta simple code
evilive, thats actually what i wanted =D. i learn more everyday! oh and the code i put before did have semi's, i was just to lazy to put them into the post. right after i posted i remembered $PHP_self doesnt give the url... anyway, thanks alot. it was quite an easy script but i just couldnt get it for some reason, thanks evilive
|
![]() |
| Viewing: Codewalkers Forums > PHP Related > PHP Coding > help with sorta simple code |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|
|
|