Home  >  Article  >  Backend Development  >  What to do if php fopen fails

What to do if php fopen fails

藏色散人
藏色散人Original
2020-07-06 09:58:504479browse

php fopen failed because "allow_url_fopen" was not activated. The solution: first find and open the "php.ini" configuration file; then enable the relevant configuration of fopen; and finally save the file.

What to do if php fopen fails

fopen() in php fails to open the file (Url)

Need to configure the relevant configuration in php.ini Turn on

fopen prototype:

resource fopen ( string $filename , string $mode [, bool $use_include_path = false [, resource $context ]] )

If PHP believes that filename specifies a registered protocol, and the protocol is registered as a network URL, PHP will check and confirm that allow_url_fopen has been activated. If it is closed, PHP will issue a warning and the call to fopen will fail.

allow_url_fopen: This option activates the fopen encapsulation protocol in the form of a URL so that URL objects such as files can be accessed. The default encapsulation protocol provides access to remote files using ftp and http protocols. Some extension libraries such as zlib may register more encapsulation protocols.

Note:

  • For security reasons, this option can only be set in php.ini.

  • #This option was introduced immediately after the release of version 4.0.3. Versions 4.0.3 and earlier can only disable this feature through the configuration item --disable-url-fopen-wrapper at compile time.

For a lot of related knowledge, please visit PHP Chinese website!

The above is the detailed content of What to do if php fopen fails. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn