CodeIgniter Forums
anchor external url with urlencode - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5)
+--- Forum: General Help (https://forum.codeigniter.com/forumdisplay.php?fid=24)
+--- Thread: anchor external url with urlencode (/showthread.php?tid=1504)



anchor external url with urlencode - pioc - 03-16-2015

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?


RE: anchor external url with urlencode - sajid19991 - 03-16-2015

(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...


RE: anchor external url with urlencode - CroNiX - 03-16-2015

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.