note 38799 deleted from function.file by nlopess

From: Date: Wed, 07 Jan 2004 14:21:23 +0000
Subject: note 38799 deleted from function.file by nlopess
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-63071@lists.php.net to get a copy of this message
Note Submitter: jsphp@kanargh.force9.co.uk ---- Re: Afterburner's comment on passing URLs via GET parameters. Your regex method is neither sufficient or necessary. There are characters other than & which will cause problems, and using a full-blown regex is rather heavyweight. This is what the functions urlencode() and rawurlencode() are for. Before incorporating your parameter-URL into a link, call urlencode() on it. urldecode() will then transform this string back into the original URL, *BUT* you don't normally have to call this as PHP will automatically urldecode() incoming GET parameters for you (you only need call it explicitly if you're using this encoding to pass the URL through some other medium, such as a data file of your own format.) Eg. $myurl = "http://somewhere/script1.php?param1=val1&param2=val2"; printf("<a href=\"http://somewhere/script2.php?url=%s\">Clicky</a>", urlencode($myurl)); [in script2.php:] $myurl = $_REQUEST['url']; # already decoded You should then be able to pass $myurl directly to file() or any other URL enabled function.

« previous php.notes (#63071) next »