CodeIgniter Forums
undefined function base_url() - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived General Discussion (https://forum.codeigniter.com/forumdisplay.php?fid=21)
+--- Thread: undefined function base_url() (/showthread.php?tid=4231)



undefined function base_url() - El Forum - 11-14-2007

[eluser]mistress_shiira[/eluser]
hi guys!kindly point out what im doing wrong here.cause i cant seem to understand why i keep getting this error.

in my controller i have a function add that calls the view below:
Code:
$this->load->helper('url');
$this->load->view('mainpage');
and in my view:
Code:
<a href='&lt;? echo base_url();?&gt;index.php/mainpage'>Main Page</a>
but then undefined function error is displayed.
same thing when i use anchor.


undefined function base_url() - El Forum - 11-14-2007

[eluser]gtech[/eluser]
works for me! you get that error if the url helper hasn't loaded successfully;

if you just put:
Code:
&lt;? echo base_url();?&gt;

do you get the same problem, if so maybe you could try autoloading the helper.

config/autoload.php

Code:
$autoload['helper'] = array('url', 'form');



undefined function base_url() - El Forum - 11-14-2007

[eluser]ELRafael[/eluser]
just to check, your php.ini allows short tags open?
&lt;? and &lt;?php ???


undefined function base_url() - El Forum - 11-14-2007

[eluser]esra[/eluser]
If short tags are not enabled in php.ini and you cannot change php.ini, you can force short tags on using the last parameter in the config.php file. You should be using &lt;?php echo base_url();?&gt; with short tags disabled or when short tags are enabled, you can use &lt;?=base_url();?&gt;.


undefined function base_url() - El Forum - 10-02-2008

[eluser]alaminx[/eluser]
get base url

$base_url=$this->config->item(base_url);