note 47132 modified in function.urlencode by tularis

From: Date: Sun, 19 Dec 2004 09:40:45 +0000
Subject: note 47132 modified in function.urlencode by tularis
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-82017@lists.php.net to get a copy of this message
---[ Editor's Note ]--- You can also use rawurlencode() here, and skip the functions provided in this note. ---[ /Editor's Nore]--- For handling slashes in redirections, (see comment from cameron at enprises dot com), try this : function myurlencode ( $TheVal ) { return urlencode (str_replace("/","%2f",$TheVal)); } function myurldecode ( $TheVal ) { return str_replace("%2f","/",urldecode ($TheVal)); } This is effectively a double urlencode for slashes and single urlencode for everything else. So, it is more "standardised" than his suggestion of using a + sign, and more readable (and search engine indexable) than a full double encode/decode. --was-- For handling slashes in redirections, (see comment from cameron at enprises dot com), try this : function myurlencode ( $TheVal ) { return urlencode (str_replace("/","%2f",$TheVal)); } function myurldecode ( $TheVal ) { return str_replace("%2f","/",urldecode ($TheVal)); } This is effectively a double urlencode for slashes and single urlencode for everything else. So, it is more "standardised" than his suggestion of using a + sign, and more readable (and search engine indexable) than a full double encode/decode. http://php.net/manual/en/function.urlencode.php

« previous php.notes (#82017) next »