Page 1 of 1

URL param's -> html equivs

Posted: Wed Jun 14, 2006 1:59 pm
by seodevhead
My php script will determine if certain parameters need to be added to a link and add them if necessary with either the ? or & depending on if other parameters are included as well.

So my question is:

Do I use the HTML equivalents in my code to produce the desired URLs w/ parameters??

Ex:

Code: Select all

if( .. need to use ? )
     $paramPrefix = '?'
else
     $paramPrefix = '&';

$parameter = 'sort=ascending';

$linkURL = $url . $paramPrefix . $parameter;
Is it okay to insert the ? or & directly or should I use thier html equivalents like so:

Code: Select all

$paramPrefix = '&';

Posted: Wed Jun 14, 2006 2:07 pm
by Roja
You can always run urlencode() on it. :)

Posted: Wed Jun 14, 2006 2:32 pm
by seodevhead
Roja wrote:You can always run urlencode() on it. :)
Oh man! I completely forgot about that! That's awesome... thanks so much Roja!