简体   繁体   English

auto_prepend_file是否不适用于ajax文件?

[英]auto_prepend_file not working for ajax files?

I was trying to solve problems I've had with global functions and variables by adding them to a file which would be automatically pre-pended. 我试图通过将全局函数和变量添加到将自动添加到文件中的文件来解决我遇到的问题。

It works for "normal" pages, like say search.php, but as soon as I do an ajax call, I get this error: 它适用于“普通”页面,例如search.php,但是一旦我执行ajax调用,就会出现此错误:

<br /> <b>Warning</b>: Unknown: failed to open stream: No such file or directory in <b>Unknown</b> on line <b>0</b><br /> <br /> <b>Fatal error</b>: Unknown: Failed opening required '../../htdocs/mosaic/include/alpha.php' (include_path='.:/opt/lampp/lib/php') in <b>Unknown</b> on line <b>0</b><br />

The ajax file is stored in htdocs/mosaic/ajax Ajax文件存储在htdocs / mosaic / ajax中

Any idea why? 知道为什么吗? Thank you 谢谢

(Running XAMPP on ubuntu 16.04) (在Ubuntu 16.04上运行XAMPP)

You're probably auto-including a file from two different files in different levels of directories: 您可能会自动包含来自不同目录级别中两个不同文件的文件:

 mosaic/include/alpha.php
 mosaic/whatever
 mosaic/ajax/file.php

The "../../" specification works from a file in "mosaic", but not from a file in any directory under it. “ ../../”规范从“ mosaic”中的文件运行,但不能从其任何目录的文件中运行。 Either use absolute file specifications (eg '/var/www/site/htdocs/mosaic/include') or fix your include_path and just use 'alpha.php' in your includes. 请使用绝对文件规范(例如'/ var / www / site / htdocs / mosaic / include')或修复您的include_path,并在包含文件中使用'alpha.php'。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM