kmu*_*nky 0 php url static include
我有两个文件:(localhost/template /)
index.php
template.php
Run Code Online (Sandbox Code Playgroud)
每当我创建一篇文章(文章系统是我正在尝试做的),我创建一个文件夹,然后我复制该文件夹中的index.php.我想在index.php中包含模板php但是作为静态url('因为文章将像文件夹子文件夹/子文件夹/ ..结构)
我试过了:include('localhost/template/template.php')没有结果.我应该如何包括它?谢谢
include方法适用于文件系统路径,而不是"url路径".解决方案是要么
给它一条绝对的道路.
-include('/some/path/to/template.php');
更改相对路径,使其在您创建的每个副本后都正确.
-include('../../template.php');
更改PHP 的包含路径,以便文件位于包含路径中.
- 可以在php.ini文件,.htaccess文件或set_include_path函数中完成.(取决于您要为其设置的数量以及您拥有的权限)