発生している問題・エラーメッセージ
下記のcontent.phpを実行するとHTTP 500エラーが発生します。
apacheのerror.logにはこのように出力されています。
[Sat Jan 27 22:15:14.144176 2018] [php7:notice] [pid 11600:tid 1904] [client ::1:56799] PHP Fatal error: Call to undefined method PEAR::start() in C:\xampp\php\pear\PEAR.php on line 218
[Sat Jan 27 22:15:14.144176 2018] [php7:notice] [pid 11600:tid 1904] [client ::1:56799] PHP Stack trace:
[Sat Jan 27 22:15:14.144176 2018] [php7:notice] [pid 11600:tid 1904] [client ::1:56799] PHP 1. {main}() C:\xampp\htdocs\test\selfphp\chap7\content.php:0
[Sat Jan 27 22:15:14.145173 2018] [php7:notice] [pid 11600:tid 1904] [client ::1:56799] PHP 2. require_once() C:\xampp\htdocs\test\selfphp\chap7\content.php:2
[Sat Jan 27 22:15:14.145173 2018] [php7:notice] [pid 11600:tid 1904] [client ::1:56799] PHP 3. PEAR_Command_Auth->start() C:\xampp\htdocs\test\selfphp\chap7\MyAuth.php:25
[Sat Jan 27 22:15:14.145173 2018] [php7:notice] [pid 11600:tid 1904] [client ::1:56799] PHP 4. PEAR_Command_Auth->__call($method = uninitialized, $arguments = uninitialized) C:\xampp\htdocs\test\selfphp\chap7\MyAuth.php:25
[Sat Jan 27 22:15:14.146176 2018] [php7:notice] [pid 11600:tid 1904] [client ::1:56799] PHP 5. trigger_error(uninitialized, uninitialized) C:\xampp\php\pear\PEAR.php:218
Authのコンストラクタに設定した内容でDB接続できることは確認済です。
どうしたらユーザ認証フォームが表示されるようになるのでしょうか。
ソースコード
■content.php
<?php require_once 'MyAuth.php'; print "ユーザ名:{$auth->getAuthData('unam')}"; ■MyAuth.php <?php require_once 'C:\xampp\php\pear\PEAR\Command\Auth.php'; function myLogin($usr, $status) { $errs = array( AUTH_IDLED => 'アイドル時間を超えています。再ログインしてください。', AUTH_EXPIRED => '期限切れです。再ログインしてください。', AUTH_WRONG_LOGIN => 'ユーザ/パスワードが誤っています。' ); require_once 'login.php'; } $driver = 'MDB2'; $opt = array( 'dsn' => 'mysqli://selfusr:selfpass@127.0.0.1/selfphp', 'table' => 'usr', 'usernamecol' => 'uid', 'passwordcol' => 'passwd', 'db_fields' => '*' ); $loginFunc = 'myLogin'; $auth = new PEAR_Command_Auth($driver, $opt, $loginFunc); $auth->start(); if(!$auth->checkAuth()) { die(); } ### 補足情報(FW/ツールのバージョンなど) PHP/7.2.0 pear/Auth 1.6.4 Creating an authentication system. pear/Auth_HTTP 2.1.8 HTTP authentication pear/Auth_PrefManager 1.2.2 Preferences management class pear/Auth_PrefManager2 2.0.0dev1 Preferences management class pear/Auth_RADIUS 1.1.0 Wrapper Classes for the RADIUS PECL. pear/Auth_SASL 1.1.0 Abstraction of various SASL mechanism responses pear/Auth_SASL2 0.2.0 Abstraction of various SASL mechanism responses
下記のような回答は推奨されていません。
このような回答には修正を依頼しましょう。
また依頼した内容が修正された場合は、修正依頼を取り消すようにしましょう。