简体   繁体   English

`require('file.php')`停止我的代码并显示空白页

[英]`require ('file.php')` stops my code and display blank page

I'm trying to call a PHP class in my project called connectBDD_PDO.class.php located in /wamp/www/publicClass/connectBDD_PDO.class.php , but when I use the function 我想打电话给我的项目中调用的PHP类connectBDD_PDO.class.php位于/wamp/www/publicClass/connectBDD_PDO.class.php ,但是当我使用的功能

require ($_SERVER["HTTP_HOST"].'/publicClass/connectBDD_PDO.class.php');

My code stops and displays a blank page, no error messages even in debugging mode. 我的代码停止并显示空白页,即使在调试模式下也没有错误消息。 Can you help me find where the problem come from ? 您能帮我找到问题的根源吗?

$_SERVER["HTTP_HOST"] usually is the domain name, depending on how your vhost configured. $_SERVER["HTTP_HOST"]通常是域名,取决于您的虚拟主机的配置方式。

A invalid path is causing the error. 无效的路径导致该错误。

Just give the absolute path of the directory where publicClass/connectBDD_PDO.class.php is located. 只需提供publicClass / connectBDD_PDO.class.php所在目录的绝对路径即可 You may use a relative path, but then it must be seen relatively from the script is including it. 您可以使用相对路径,但是必须从包含它的脚本中相对地看到它。

When seeing a blank page, probably a HTTP 500 error is invoked. 看到空白页时,可能会调用HTTP 500错误。 You may place ini_set('display_errors', true); 您可以放置ini_set('display_errors', true); at first line to debug in browser, but does not guarantee to show it. 第一行在浏览器中进行调试,但不能保证将其显示出来。

Example assuming 示例假设

/var/www/www.foo.com/htdocs/index.php
/var/www/publicClass/connectBDD_PDO.class.php

Then you can include this like 然后,您可以像这样包含

// absolute path
require('/var/www/publicClass/connectBDD_PDO.class.php');

or 要么

// relative path
require('../../publicClass/connectBDD_PDO.class.php');

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

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