Posts

Showing posts with the label Include

Codeigniter: How To Include Javascript Files

Answer : You need to use the base_url() to include the javascript file in your VIEW. So, in the view_demo.php file: <script type="text/javascript" src="<?=base_url()?>js/jquery.js" ></script> <script type="text/javascript" src="<?=base_url()?>js/ajax.js" ></script> You will need the URL helper loaded. To load the helper you need to put on your demo.php controller: $this->load->helper('url'); You can also autoload on \config\autoload.php on the helpers array. More info about base_url(): http://www.codeigniter.com/user_guide/helpers/url_helper.html#base_url https://codeigniter.com/user_guide/general/styleguide.html#short-open-tags You wouldn't include JS files within the PHP, they would be output as script tags within the HTML you produce which you may be producing as output from the PHP script. As far as I know, there is no built in CodeIginiter function to include this outpu...