?
Solved

$php_self include addressbar variables

Posted on 2005-04-15
13
Medium Priority
?
891 Views
Last Modified: 2013-11-18
How do you get $php_self to include the variables after the '?' delimeter?
0
Comment
Question by:benwiggy
  • 5
  • 4
  • 2
  • +1
13 Comments
 
LVL 6

Expert Comment

by:peyox
ID: 13795657
Hi Benwiggy, please clarify your question.
0
 
LVL 6

Author Comment

by:benwiggy
ID: 13795670
When you use $php_self on a page with the address: page1.php?bla=1&t=22 you just get page1.php - I want to get the whole lot...
0
 
LVL 6

Expert Comment

by:peyox
ID: 13795699
Ok, now you talking...

Something like this?

echo $_SERVER["REQUEST_URI"];
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 11

Expert Comment

by:neester
ID: 13795966
you mean:

$_SEVER['query_string'];
0
 
LVL 11

Expert Comment

by:neester
ID: 13795973
http://au.php.net/reserved.variables

'QUERY_STRING'

    The query string, if any, via which the page was accessed.
0
 
LVL 11

Assisted Solution

by:neester
neester earned 100 total points
ID: 13795975
This is everything to the right of the ? in your example:
page1.php?bla=1&t=22

so this: bla=1&t=22

0
 
LVL 2

Assisted Solution

by:Marvin_Carredo
Marvin_Carredo earned 100 total points
ID: 13796327
http://localhost:8080/my/path/info?test=1

$_SERVER['HTTP_HOST']       // returns: localhost:8080
$_SERVER['SCRIPT_NAME'];   // returns: /my/path/info
$_SERVER['QUERY_STRING']; // returns: test=1
0
 
LVL 2

Expert Comment

by:Marvin_Carredo
ID: 13796334
by the way you can also use  $_SERVER['REQUEST_URI'] instead of  $_SERVER['SCRIPT_NAME']
0
 
LVL 11

Expert Comment

by:neester
ID: 13796339
Request_Uri includes the slash though.
And scriptname is just the filename :)
0
 
LVL 6

Expert Comment

by:peyox
ID: 13797280
It seems for me, that he wants script name + query string, so REQUEST_URI is just enough. Benwiggy??
0
 
LVL 6

Accepted Solution

by:
peyox earned 300 total points
ID: 13797297
Run this code, and choose which variables you want.

<?
   echo "REQUEST_URI: ".$_SERVER["REQUEST_URI"];
   echo "<br>";
   echo "PHP_SELF: ".$_SERVER["PHP_SELF"];
   echo "<br>";
   echo "HTTP_HOST: ".$_SERVER['HTTP_HOST'];
   echo "<br>";
   echo "SCRIPT_NAME: ".$_SERVER['SCRIPT_NAME'];
   echo "<br>";
   echo "QUERY_STRING: ".$_SERVER['QUERY_STRING'];
?>

One my windows machine I get this:
URL:
http://localhost/ee/get_string.php?a=3&v=2

REQUEST_URI: /ee/get_string.php?a=3&v=2
PHP_SELF: /ee/get_string.php
HTTP_HOST: localhost
SCRIPT_NAME: /php/php.exe
QUERY_STRING: a=3&v=2

good luck
0
 
LVL 11

Expert Comment

by:neester
ID: 13797360
Good answer there *peyox*
0
 
LVL 6

Author Comment

by:benwiggy
ID: 13799292
Sorry guys will take a look at your solutions tomorrow morning am tired (back from party) and need my sleep - then I'll up the points value and award points as I think is fair.

Laters,
Benjamin
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Preface This is the third article about the EE Collaborative Login Project. A Better Website Login System (http://www.experts-exchange.com/A_2902.html) introduces the Login System and shows how to implement a login page. The EE Collaborative Logi…
These days socially coordinated efforts have turned into a critical requirement for enterprises.
The viewer will the learn the benefit of plain text editors and code an HTML5 based template for use in further tutorials.
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).
Suggested Courses
Course of the Month17 days, 8 hours left to enroll

830 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question