我根据URI段动态设置文件包含路径,如下所示
http://script/profile/
$segments = explode( '/', $uri );
$file = end( $segments ) . '.php';
foreach ( $segments as $segment ) {
$dirs[] = $segment;
}
$include_path = rt_trailingslash_dir( root()->template_dir ) . implode( DIRECTORY_SEPARATOR, $dirs );
print_r($include_path . '/' . $file);
c:/xampp/htdocs/.../template\profile\profile.php
include $include_path . DIRECTORY_SEPARATOR . $file;
template\profile.php
哪个错了。应该是
template\profile\profile.php
我不知道我在做什么错误。?