【问题标题】:code igniter's localhost mamp model works but view does not代码点火器的 localhost mamp 模型有效,但视图无效
【发布时间】:2012-03-29 05:54:57
【问题描述】:

我有一个奇怪的问题:

我正在使用 MAMP 和 Codeigniter,我看到该视图在浏览器上没有显示任何内容。模型工作,数据库已连接。 这是在本地主机上不起作用的代码:

$this->load->view('test/db_tester_view',$data);

遗憾的是没有错误消息!!?但这里是配置:

$config['base_url'] = 'http://localhost:8888';
$config['index_page'] = '';
$config['uri_protocol'] = 'REQUEST_URI';

我花了 20 个小时在这上面,感谢您的帮助

【问题讨论】:

  • 开启错误报告。
  • 您使用的网址是什么?您有 .htaccess 文件吗?

标签: codeigniter view localhost mamp


【解决方案1】:

一些提示:

确保像往常一样打开错误报告(这应该在您的引导文件中,index.php):

error_reporting(E_ALL);
ini_set('display_errors', 1);

确保您没有在脚本的其他地方禁用这些指令。

Windows 和 *NIX 处理大写/小写文件名的方式不同。确保您的文件全部标准化为小写,以避免不同操作系统出现问题。

基本网址需要尾部斜杠:

/*
|--------------------------------------------------------------------------
| Base Site URL
|--------------------------------------------------------------------------
|
| URL to your CodeIgniter root. Typically this will be your base URL,
| WITH a trailing slash:
|
|   http://example.com/
|
| If this is not set then CodeIgniter will guess the protocol, domain and
| path to your installation.
|
*/
$config['base_url'] = 'http://localhost:8888/';
// OR...
$config['base_url'] = ''; // automagic

如果您不需要明确设置端口,则可以将其删除。

【讨论】:

  • 那行得通,谢谢... OMG ...我花了 24 小时在这上面!我不得不将配置文件与基础文件进行比较,另一个问题是我已将目录放入 htdocs ......由于某种原因,MAMP 不够聪明,无法从另一个导演那里获取它! WOHO..它现在可以工作了!
  • 那么它是尾部斜杠还是文件名大小写?
  • 我发现这种调试方法很有用。在我的情况下,当调用视图时,我的连字符被转换为长连字符。这成功了!
猜你喜欢
  • 1970-01-01
  • 2017-12-29
  • 2020-07-02
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2022-12-15
  • 1970-01-01
相关资源
最近更新 更多