CodeIgniter Forums

Full Version: anchor external url with urlencode
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi everybody,
i'm trying in a view to make a link to an external url like this :


Code:
$c_url_redir = 'http://www.example.com/content.php?id=test&article=3';
if (isset($c_url_redir)){
   echo anchor(urlencode($c_url_redir), "go", 'class="pure-button pure-button-primary" target="_blank"');
}


CI add base_url to my external url...Why and how to fix that?
(03-16-2015, 03:08 AM)pioc Wrote: [ -> ]Hi everybody,
i'm trying in a view to make a link to an external url like this :



Code:
$c_url_redir = 'http://www.example.com/content.php?id=test&article=3';
if (isset($c_url_redir)){
   echo anchor(urlencode($c_url_redir), "go", 'class="pure-button pure-button-primary" target="_blank"');
}


CI add base_url to my external url...Why and how to fix that?

correct way to do this

Code:
$c_url_redir = 'http://www.example.com/content.php?id=test&article=3';
if (isset($c_url_redir)){
   echo anchor($c_url_redir, "go", 'class="pure-button pure-button-primary" target="_blank"');
}

ci's anchor function is not able to detect external url when you encode it...
CI's helper functions, like anchor(), are helpers for YOUR CI app. If you want to link to something external outside of your app, don't use CI's helpers and create a traditional <a> tag.