Home  >  Article  >  Backend Development  >  Can PHP's include include a remote config.php on the external network? And get the constants in the config

Can PHP's include include a remote config.php on the external network? And get the constants in the config

WBOY
WBOYOriginal
2016-07-06 13:53:281135browse

Can PHP’s include include a remote config.php on the external network? And get the constants in the config

Reply content:

Can PHP’s include include a remote config.php on the external network? And get the constants in the config

If you could do this directly, then the network would be really unsafe.

include can include remote files, but the code of the remote config.php file cannot be obtained because it will be parsed. You can only get the content output after parsing. Then you might as well directly pull the remote json file with curl, and then parse it to get the value.

You can
use readfile() better
http://php.net/manual/zh/function.include.php

What a dangerous idea. Use the API idea

Are you afraid that it will be inconvenient for others to criticize you? It's too dangerous. Use a solution like API or RPC.

It depends on whether the remote server can parse PHP. If not, the remote server will access the original content of the file. If it can, the parsed html content will be returned.

It is not safe to include remote files. It is recommended to use API

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