URL param's -> html equivs

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
seodevhead
Forum Regular
Posts: 705
Joined: Sat Oct 08, 2005 8:18 pm
Location: Windermere, FL

URL param's -> html equivs

Post 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 = '&';
Roja
Tutorials Group
Posts: 2692
Joined: Sun Jan 04, 2004 10:30 pm

Post by Roja »

You can always run urlencode() on it. :)
User avatar
seodevhead
Forum Regular
Posts: 705
Joined: Sat Oct 08, 2005 8:18 pm
Location: Windermere, FL

Post 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!
Post Reply