Home > Article > Backend Development > file_put_contents error: failed to open stream: Invalid argument One reason, invalidromcontents_PHP tutorial
When testing the nilcms system today, an error occurred, causing the cache to fail to be updated:
<p>file_put_contents(C:\UPUPW_AP5.4\vhosts\d.tv\NilCMS_APP\include_run/config_site.php): failed to open stream: Invalid argument C:\UPUPW_AP5.4\vhosts\d.tv\NilCMS_20160520\core\common.php 129</p>
The test environment uses win7 64-bit and uses the UPUPW environment suite.
The file_put_contents function is used to generate files. There is no problem in generating other files in this directory. Only config_site.php cannot be written. Tangled. . .
Analysis process:
1.config_site.php file will be loaded directly before the nilcms system is run. Will it affect writing? After testing, loading the file and then modifying it worked without any problems.
2. Looking for problems, struggling, and feeling speechless.
3. Found that the function used when importing the config_site.php file is require_once. After changing it to require, I found that there was no problem generating cache. Problem solved.
Some notes:
1. I have not encountered such problems when using the wamp environment (XWAMP) I built myself.
2. There is no such problem when using Linux virtual host environment.
3. I don’t know why replacing this function can solve this problem. Friends who know can share it.
4. I feel much better^_^