PHP 확장 프로그램에서 가장 이상한 문제가 있습니다. 명령 줄에서 다음과 같이 사용하면 :PHP 확장 기능 : httpd (Apache) 서버가 아닌 명령 행에서 작동합니다.
php -r '$mc = new MyClass("foo"); echo $mc->getField();'
예상대로 "foo"가 출력됩니다.
그러나 index.php에서 동일한 작업을 수행하려고하면 클래스를 찾을 수 없습니다.
Fatal error: Class 'MyClass' not found in /var/www/html/index.php on line 12
어떻게 이런 일이 벌어 질 수 있습니까? 필자는 php -r 명령을 실행할 때 httpd가 자신과 동일한 사용자로 실행되도록 설정했습니다.
내 index.php를 그렇게 다음과 같습니다 있기 때문에,
# PHP Configuration for Apache
#
# Load the apache module
#
LoadModule php5_module modules/libphp5.so
#
# Cause the PHP interpreter handle files with a .php extension.
#
<Files *.php>
SetOutputFilter PHP
SetInputFilter PHP
LimitRequestBody 9524288
</Files>
AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps
#
# Add index.php to the list of files that will be served as directory
# indexes.
#
DirectoryIndex index.php
그리고 분명히 내 php.ini 파일이 올바르게 설정되어
이<html>
<head>
<title>PHP Test</title>
</head>
<body>
<p>
<?php
error_reporting(E_ALL);
ini_set('display_errors', '1');
$mc = new MyClass("foo");
echo $mc->getField();
?>
</p>
</body>
</html>
내 httpd.conf 파일의 PHP 부분과 같이 보인다 내 PHP -R 명령이 작동합니다. 이 문제의 원인은 무엇입니까?