note 42860 rejected from function.parse-url by aidan

From: Date: Sat, 03 Jul 2004 06:51:19 +0000
Subject: note 42860 rejected from function.parse-url by aidan
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-72355@lists.php.net to get a copy of this message
Note Submitter: mwwaygoo AT hotm@il.com ---- Its all very well being able to split and reconstruct a url. BUT how on earth do you get the FULL url of the current page. The $_SERVER settings only show parts, it would be nice if php actually did the parse_url on the current page. And whats with the PHP_SELF, SCRIPT_NAME and REQUEST_URI. SCRIPT_NAME includes the path, so it is the same as PHP_SELF, and REQUEST_URI doesnt include fragments. I am aware of web-browsers only really using fragments but surely if your going to include them in URL's then you should have access to their values, otherwise why include it in the parse_url function. Currently phpinfo() using the url http://localhost:80/test/phpinfo.php?x=1#section1 produces:- _SERVER["HTTP_HOST"] localhost _SERVER["HTTP_USER_AGENT"] Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0; .NET CLR 1.1.4322) _SERVER["REMOTE_ADDR"] 127.0.0.1 _SERVER["REMOTE_PORT"] 3583 _SERVER["SCRIPT_FILENAME"] c:/wwwroot/test/phpinfo.php _SERVER["SERVER_ADDR"] 127.0.0.1 _SERVER["SERVER_NAME"] localhost _SERVER["SERVER_PORT"] 80 _SERVER["SERVER_SIGNATURE"] <ADDRESS>Apache/1.3.28 Server at localhost Port 80</ADDRESS> _SERVER["SERVER_SOFTWARE"] Apache/1.3.28 (Win32) PHP/4.3.4 _SERVER["GATEWAY_INTERFACE"] CGI/1.1 _SERVER["SERVER_PROTOCOL"] HTTP/1.1 _SERVER["REQUEST_METHOD"] GET _SERVER["QUERY_STRING"] x=1 _SERVER["REQUEST_URI"] /test/phpinfo.php?x=1 _SERVER["SCRIPT_NAME"] /test/phpinfo.php _SERVER["PHP_SELF"] /test/phpinfo.php _SERVER["argv"] Array ( [0] => x=1 ) _SERVER["argc"] 1 It would be nice to see a more usable detail added to it, similar to:- $_SERVER['url'] http://localhost:80/test/phpinfo.php?x=1#section1 $_SERVER['parsed_url']['scheme'] http $_SERVER['parsed_url']['host'] localhost $_SERVER['parsed_url']['user'] $_SERVER['parsed_url']['pass'] $_SERVER['parsed_url']['path'] /test $_SERVER['parsed_url']['script'] phpinfo.php $_SERVER['parsed_url']['port'] 80 $_SERVER['parsed_url']['query'] x=1 $_SERVER['parsed_url']['fragment'] section1

« previous php.notes (#72355) next »