我正试图在另一个目录中包含一个PHP文件。
这是我的文件结构
settings\ manage.php website \ index.php main.js main.css对于manage.php
echo 'Welcome to the manager! Here is your website:'; include('../website/index.php');的index.php
<script src='main.js'></script> <link rel="stylesheet" type="text/css" href="main.css">所以,当我加载manage.php时,我没有得到main.js或main.css。 我怎样才能使这个工作? 也许包括是不是正确的路要走? 我无法修改网站文件夹中的任何内容。
[我知道iFraming是一个可能的解决方案,但我希望能得到另一个答案]
I am trying to include a PHP file in another directory.
Here is my file structure
settings\ manage.php website \ index.php main.js main.cssFor manage.php
echo 'Welcome to the manager! Here is your website:'; include('../website/index.php');index.php
<script src='main.js'></script> <link rel="stylesheet" type="text/css" href="main.css">So, when I load manage.php, I do not get main.js or main.css. How can I get this to work? Maybe include is not the right way to go? I cannot modify anything in the website folder.
[I know iFraming is a possible solution but I'm hoping to get another answer]
最满意答案
基于以下问题的评论:如果你想为你的用户包含一些函数/代码(而不是其他方式;你在代码中包括用户的东西),你应该查看auto_prepend_file指令。
基本上,您可以在您的php.ini文件中指定要在主文件之前预先安装(作为require )某个PHP文件。
编辑:由于你没有访问php.ini,但你可以使用.htaccess文件,你可以把它放在你的.htaccess :
php_value auto_prepend_file "/path/to/your/file.php"Based on the comment below the question: If you want to include some functions / code for your users (instead of the other way around; you including user's stuff in your code), you should look into the auto_prepend_file directive.
Basically, you specify in your php.ini file that you want to prepend (as a require) a certain php file before the main file.
Edit: As you don't have access to php.ini but you can use a .htaccess file, you can put this in your .htaccess:
php_value auto_prepend_file "/path/to/your/file.php"更多推荐
发布评论