添加php.ini后my_phpinfo.php空白及Loaded Configuration File显示None求助
Let me break down what's going on here and walk you through fixing it step by step:
为什么“Loaded Configuration File”显示“None”?
When PHP starts up, it looks for the php.ini file in a specific order: first the path set during compilation, then the directory pointed to by the PHPRC environment variable, next system directories like your C:/Windows, and finally the PHP installation directory.
The "配置文件路径" you see in phpinfo is where PHP expects to find php.ini, but if there's no valid php.ini in that location, it will show "None". That's exactly what happened to you initially—there was no php.ini in C:/Windows, so PHP ran with its default built-in configuration instead of a custom one.
You don't need a "separate real php.ini" file!
The php.ini-development and php.ini-production files in your C:/PHP folder are official, valid configuration templates from PHP itself—they're not "fake" or incomplete. The only issue is their names don't match what PHP is looking for (php.ini).
Your earlier mistake was copying one of these files to C:/Windows and renaming it. This likely caused PHP to hit a parsing error or permission issue when loading the file, which is why your phpinfo page went blank (PHP often fails silently with configuration errors, resulting in an empty page).
Correct Steps to Fix This
Undo your earlier misstep
Delete thephp.inifile you copied toC:/Windowsto eliminate any conflicting configuration sources.Use the template in your PHP installation folder
- Open your
C:/PHPdirectory (where thephp.ini-developmentandphp.ini-productionfiles live). - For a development environment (which sounds like what you're using), copy
php.ini-developmentand rename the copy tophp.ini. If this were a production server, you'd usephp.ini-productioninstead—it disables debug features for better performance and security.
- Open your
Ensure PHP finds your new configuration file
You have two reliable ways to do this:- Option 1: Set the PHPRC environment variable
Right-click "This PC" → Properties → Advanced System Settings → Environment Variables. Under System Variables, create a new variable:- Variable name:
PHPRC - Variable value:
C:/PHP
Save the changes, then restart your local server (the one running onlocalhost:4000). PHP will now look forphp.iniin this directory first.
- Variable name:
- Option 2: Specify the config file when starting the built-in server
If you're using PHP's built-in server (started withphp -S localhost:4000), add the-cflag to point directly to your new config:php -S localhost:4000 -c "C:/PHP/php.ini"
- Option 1: Set the PHPRC environment variable
Verify the fix
Restart your server, then reloadlocalhost:4000/my_phpinfo.php. The "Loaded Configuration File" should now showC:/PHP/php.ini, and the page should display all the configuration details instead of being blank.
If the page is still blank...
Open your new php.ini file and find these settings:
display_errors = On error_reporting = E_ALL
Set them to the values above, save the file, and restart your server. This will force PHP to display any errors that are causing the blank page, making it easy to troubleshoot remaining issues.
内容的提问来源于stack exchange,提问作者Yogesh Bhatt

