What's better? Using 'base_url ()' or './'?
I have been using CodeIgniter Framework for several months now.
In views, I usually include external css and js with base_url()
like this:
<link href="<?php echo base_url() ?>assets/css/custom.css" rel="stylesheet">
But someone tells me that using it ./
also works. And it is true.
So which is better (safe)?
+3
source to share
4 answers
base_url()
is just a helper (URL helper in CI). Some people are just easier to use, so I don't see any additional security with base_url()
.
In the case of ease of use, I see that so many people use it as
<?php echo base_url()."controller/function";?>
while actually you can use it like
<?php echo base_url("controller/function");?>
+2
source to share