Php 在codeigniter中获取控制器文件夹名称?
如果控制器中有这样的文件夹:Php 在codeigniter中获取控制器文件夹名称?,php,codeigniter,url-routing,Php,Codeigniter,Url Routing,如果控制器中有这样的文件夹: controller/folder/class/method 如何获取当前文件夹 对于类:$this->router->class 对于方法:$this->router->method 如何获取文件夹名称或完整路径???您可以签出 要获取当前uri,请执行以下操作: $this->uri->uri_string() 要获取示例中的控制器文件夹,请执行以下操作: $this->uri->segment(1) 你可以退房 要获取当前uri,
controller/folder/class/method
如何获取当前文件夹
对于类:$this->router->class
对于方法:$this->router->method
如何获取文件夹名称或完整路径???您可以签出
要获取当前uri,请执行以下操作:
$this->uri->uri_string()
要获取示例中的控制器文件夹,请执行以下操作:
$this->uri->segment(1)
你可以退房
要获取当前uri,请执行以下操作:
$this->uri->uri_string()
要获取示例中的控制器文件夹,请执行以下操作:
$this->uri->segment(1)
试试看:
echo $this->uri->segment(1);
它将在控制器下显示您的文件夹名称
例:
试试看:
echo $this->uri->segment(1);
它将在控制器下显示您的文件夹名称
例:
你可以用
从system/core/Router.php
:
/**
* Fetch the sub-directory (if any) that contains the requested controller class
*
* @access public
* @return string
*/
function fetch_directory()
{
return $this->directory;
}
你可以用
从system/core/Router.php
:
/**
* Fetch the sub-directory (if any) that contains the requested controller class
*
* @access public
* @return string
*/
function fetch_directory()
{
return $this->directory;
}
我一直使用:
$this->uri->segment(1)
获取我的控制器名称。不确定这是否是文件夹名称,因为您正在查找文件夹名称。我一直使用:
$this->uri->segment(1)
获取我的控制器名称。由于您正在查找文件夹名称,因此不确定这是否为默认名称