turkuas Posted August 22, 2013 Share Posted August 22, 2013 hi all, i am a newbie member of php world, i need to learn the answer of a simple question why "preg_replace('/\@!$@&()\'*+,;=%]+)"\](.+)\[\!url\]/', '<a href="$1">$2</a>', $string)" expression adds my own site address at the beginning of the link created? such as http://www.mysite.com/www.thesitepreg_replace_created.com Quote Link to comment Share on other sites More sharing options...
.josh Posted August 22, 2013 Share Posted August 22, 2013 this preg_replace isn't doing that.. the URLs already have your site address in them by the time $string is passed to it. Or else, the URLs are relative links and you are looking at the rendered html on your page..well since they are relative urls, the browser points to your site. In any case, this preg_replace isn't the issue. Quote Link to comment Share on other sites More sharing options...
turkuas Posted August 22, 2013 Author Share Posted August 22, 2013 i am using this expression instead of i mentioned above, but this one directly converts a text to url without syntax "$msg = preg_replace( "`((http)+(s)?:(//)|(www\.))((\w|\.|\-|_)+)(/)?(\S+)?`i", "<a target=_blank href=\"http\\3://\\5\\6\\8\\9\" title=\"\\0\">\\5\\6</a>", $msg);"and it doesnt adds my site's url. what is the difference? Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.