Products
GG网络技术分享 2025-03-18 16:12 11
I am facing a strange issue with WordPress. When I put this line as a code snippet in a blog post:
$app = require_once __DIR__.\'/../bootstrap/app.php\';
I get a 404 error when I try to preview the page, and I wont be able to save the post at all but if I make the line of code incorrect for example, remove the last \'e\' from require, this way:
$app = requir_once __DIR__.\'/../bootstrap/app.php\';
everything works fine. Is the code somehow executing and causing problems?
图片转代码服务由CSDN问答提供
感谢您的意见,我们尽快改进~
功能建议我正面临着WordPress的一个奇怪问题。 当我把这一行作为代码片段放在博客文章中时:</ p>
$ app = require_once __DIR __。\'/ .. / bootstrap / app.php\'; </ 代码> </ pre>
当我尝试预览页面时出现404错误,我根本无法保存帖子但是如果我使代码行不正确,例如删除 来自require的最后一个\'e\',这样:</ p>
$ app = requir_once __DIR __。\'/ .. / bootstrap / app.php\'; </ code> < / pre>
一切正常。 代码是以某种方式执行并导致问题吗?</ p>
</ div>
网友观点:
Your web host probably has a paranoid web application firewall (most likely mod_security) enabled, with rules to block requests which contain data which looks like PHP code.
Contact your web host and request that they turn this feature off.
###
Wordpress is a little funny that way, try using get_stylesheet_directory() function. This will return the path to your theme directory.
require_once( get_stylesheet_directory() . \'/path/to/bootstrap.css );
Also the require_once function doesn\'t return anything so there is no point trying to assign it to a variable.
Demand feedback