简体   繁体   中英

Can't find include_path from browser but works in Terminal

I am new to server admin and PHP so my apologies. This one really has me stuck. I rebooted the EC2 server but still no luck.

PHP File

<?php
require_once "System.php";
var_dump(class_exists('System', false));
?>

Terminal (It Works)

[ec2-user@domU-12-31-39-10-26-22 current]$ php phpcheck.php
bool(true)

Browser - it doesn't find the file

Warning: require_once(System.php): failed to open stream: No such file or directory in /etc/httpd/opt/app/current/phpcheck.php on line 2 Fatal error: require_once(): Failed opening required 'System.php' (include_path='.:/home/ec2-user/pear/share/pear') in /etc/httpd/opt/app/current/phpcheck.php on line 2

When I typically have these problems, I simply add this:

require_once(dirname(__FILE__) . '/System.php');

That way you get a full path to the file.

However, your include_path looks a little wonky. -kc

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.

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