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
[!--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;

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.