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
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.
A invalid path is causing the error.
Just give the absolute path of the directory where publicClass/connectBDD_PDO.class.php is located. 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. You may place 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');
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.