[英]Codeigniter call Function in Controller without index.php
[英]Not able to call the function within the index.php from the controller
所以我正在学习PHP,并且从一些非常基础的东西开始。
我正在尝试从控制器文件夹中的文件调用函数,但是它将无法正常工作。
我已经能够成功地回显我在URL栏中键入的任何内容,但它不会在控制器的一部分中打印出其他index.php文件中的消息,但是当然会继续回显URL的任何消息输入。 我想念什么吗?
所以这是我坐在MVC文件夹之外的文件,它是一个index.php文件:
<?php
$url = $_GET['url'];
echo $url;
require 'controllers/' . $url . '.php';
$controller = new $url;
?>
这是我要调用的controllers文件夹中的index.php文件中包含的内容:
<?php
class Index {
function __construct(){
echo 'We are in index';
}
}
?>
我的.htaccess文件如下所示:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule ^(.*)$ /index.php?url=$1 [QSA,L]
如果您使用的是Linux,则将controller/index.php
更改为controller/Index.php
,然后尝试使用所有小写字母访问索引。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.