致命错误:调用未定义函数base_url()在C:\wamp\www\Test-CI\application\views\layout.php第5行 [英] Fatal error: Call to undefined function base_url() in C:\wamp\www\Test-CI\application\views\layout.php on line 5

查看:277
本文介绍了致命错误:调用未定义函数base_url()在C:\wamp\www\Test-CI\application\views\layout.php第5行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Hello我是新的CodeIgniter和PHP,我试图设置它的第一时间,但它给出以下错误。


致命错误:调用

中的未定义函数base_url()


  1. C:\wamp\www\Test-CI\application\views\layout.php第5行


  2. {main}()IN ..\index.php:0 require_once('C:\wamp\www\Test-CI\system\core\CodeIgniter.php')IN .. \index.php:202


  3. call_user_func_array()IN ..\CodeIgniter.php:359


  4. 首页 - > index()IN ..\CodeIgniter.php:0


  5. CI_Loader-> view \\home.php:17


  6. CI_Loader - > _ ci_load()IN ..\Loader.php:419


  7. include('C:\wamp\www\Test-CI\application\views\layout.php')IN ..\Loader.php:833



我的代码:

 < html> 
< head>
< meta http-equiv =Content-typecontent =text / html; charset = utf-8>
< title> Galleriffic |带有外部控件的自定义布局< / title>
< link rel =stylesheethref =<?php base_url();?> /assets/css/basic.csstype =text / css/>
< link rel =stylesheethref =<?php base_url();?> /assets/css/galleriffic-5.csstype =text / css/&

<! - < link rel =stylesheethref =<?php base_url();?> /assets/css/white.csstype =text / css /> - >
< link rel =stylesheethref =<?php base_url();?> /assets/css/black.csstype =text / css/>

< script type =text / javascriptsrc =<?php base_url();?> /assets/js/jquery-1.3.2.js><脚本>
< script type =text / javascriptsrc =<?php base_url();?> /assets/js/jquery.history.js>< / script&
< script type =text / javascriptsrc =<?php base_url();?> /assets/js/jquery.galleriffic.js>< / script&
< script type =text / javascriptsrc =<?php base_url();?> /assets/js/jquery.opacityrollover.js>< / script&
<! - 我们只希望在禁用javascript时显示thunbnails - >
< script type =text / javascript>
document.write('< style> .noscript {display:none;}< / style>');
< / script>
< / head>


解决方案

您必须载入 url 帮助程序访问该函数。
您可以添加

  $ this-> load-> helper('url'); 




$ b

,以便让它在任何地方自动加载,请确保应用程序/ config / autoload.php 看起来像

  $ autoload ['helper'] = array('url'); 

在该数组中具有'url'如上所示)。


Hello I am new to CodeIgniter and PHP, I am trying to setup it for the firs time, but it give the following error.

Fatal error: Call to undefined function base_url() in

  1. C:\wamp\www\Test-CI\application\views\layout.php on line 5
     
  2. {main}( ) IN ..\index.php:0 require_once('C:\wamp\www\Test-CI\system\core\CodeIgniter.php' ) IN ..\index.php:202

  3. call_user_func_array ( ) IN ..\CodeIgniter.php:359

  4. Home->index( ) IN ..\CodeIgniter.php:0

  5. CI_Loader->view( ) IN ..\home.php:17

  6. CI_Loader->_ci_load( ) IN ..\Loader.php:419

  7. include('C:\wamp\www\Test-CI\application\views\layout.php' ) IN ..\Loader.php:833

My code :

 <html>
    <head>
        <meta http-equiv="Content-type" content="text/html; charset=utf-8">
        <title>Galleriffic | Custom layout with external controls</title>
        <link rel="stylesheet" href="<?php base_url(); ?>/assets/css/basic.css" type="text/css" />
        <link rel="stylesheet" href="<?php base_url(); ?>/assets/css/galleriffic-5.css" type="text/css" />

        <!-- <link rel="stylesheet" href="<?php base_url(); ?>/assets/css/white.css" type="text/css" /> -->
        <link rel="stylesheet" href="<?php base_url(); ?>/assets/css/black.css" type="text/css" />

        <script type="text/javascript" src="<?php base_url(); ?>/assets/js/jquery-1.3.2.js"></script>
        <script type="text/javascript" src="<?php base_url(); ?>/assets/js/jquery.history.js"></script>
        <script type="text/javascript" src="<?php base_url(); ?>/assets/js/jquery.galleriffic.js"></script>
        <script type="text/javascript" src="<?php base_url(); ?>/assets/js/jquery.opacityrollover.js"></script>
        <!-- We only want the thunbnails to display when javascript is disabled -->
        <script type="text/javascript">
            document.write('<style>.noscript { display: none; }</style>');
        </script>
    </head>

解决方案

You have to load the url helper to access that function. Either you add

$this->load->helper('url');

somewhere in your controller.

Alternately, to have it be loaded automatically everywhere, make sure the line in application/config/autoload.php that looks like

$autoload['helper'] = array('url');

has 'url' in that array (as shown above).

这篇关于致命错误:调用未定义函数base_url()在C:\wamp\www\Test-CI\application\views\layout.php第5行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆