0

新しいラップトップを入手し、新しいバージョンの XAMPP をインストールしました。作業中のシステムを移動しましたが、このコンピューターでは正しく機能していません。

私が認識した最初の問題は、それを含むファイルに関連する場所からのファイルが含まれていないことでした。私のconfig.phpファイルだけでなく、includes/ディレクトリにもファイルがありinclude.phpます。が と同じフォルダにあるにもかかわらず、include.phpファイルに入力する必要があります。私の他のコンピューターでは、.require 'includes/config.php';config.phpinclude.phprequire 'config.php';

また、インクルードされたファイルが表示しているメイン ファイルで読み込まれなかったため、変数と定数が定義されていないため、自動定義されているように見えますか?

Notice: Use of undefined constant DB_HOST - assumed 'DB_HOST' in C:\xampp\htdocs\Xion\includes\include.php on line 6

これは、新しいバージョンの PHP の構成に問題がありますか?

4

2 に答える 2

1

Usually PHP core setting include_path contains the current path as well: it's denoted by . (a dot), added to a list of included pathes:

include_path=".;c:\php\includes"

Quoting the doc:

Using a . in the include path allows for relative includes as it means the current directory. However, it is more efficient to explicitly use include './file' than having PHP always check the current directory for every include.

And yes, any barename (a non-quoted string) will be processed as a constant name by PHP. If this constant is not defined (like in your case), PHP will convert it to a string (issuing a notice, though).

于 2013-06-06T23:15:28.880 に答える