Jump to content

PHP to Strip All Characters Not Allowed in URL


casbboy

Recommended Posts

I have a mod-rewrite working that puts the title of an article into an html looking page like so.

[a href=\"http://www.sample.com/name-of-file.html\" target=\"_blank\"]http://www.sample.com/name-of-file.html[/a]

I want to make sure that characters not allowed in the URL don't make it in there.

Is there a PHP function that removes everything that typically isn't allowed in an URL address?

such as ( ) " ' html tags carrots and more?

Thanks
Ryan
Link to comment
Share on other sites

[!--quoteo(post=380391:date=Jun 5 2006, 10:06 PM:name=casbboy)--][div class=\'quotetop\']QUOTE(casbboy @ Jun 5 2006, 10:06 PM) [snapback]380391[/snapback][/div][div class=\'quotemain\'][!--quotec--]
I have a mod-rewrite working that puts the title of an article into an html looking page like so.

[a href=\"http://www.sample.com/name-of-file.html\" target=\"_blank\"]http://www.sample.com/name-of-file.html[/a]

I want to make sure that characters not allowed in the URL don't make it in there.

Is there a PHP function that removes everything that typically isn't allowed in an URL address?

such as ( ) " ' html tags carrots and more?

Thanks
Ryan
[/quote]

Try str_replace or try eregi

webaddress="www.[]'^mydomain.com";
webresult=str_repalce("[]\'\^\","",$webaddress);

echo $webresult;
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.