Home > Backend Development > PHP Tutorial > file_get_contents cannot obtain the URL with port_PHP tutorial

file_get_contents cannot obtain the URL with port_PHP tutorial

WBOY
Release: 2016-07-13 10:57:24
Original
1452 people have browsed it

This article will introduce to you the solution to the problem that file_get_contents cannot obtain the URL with port. Students who need to know more can refer to it.


Let’s first understand the file_get_contents() function. The official introduction says that it reads the entire file into a string.


Example

echo file_get_contents("test.txt");
?>

Output:

This is a test file with test text.

Similarly this function can also be used to obtain content on the remote server


file_get_contents('http://www.bKjia.c0m');

There is no problem in this way, but if I bring a port, there will be a problem


For example:


file_get_contents('http://localhost:12345');


Nothing is gained.

The solution is: turn off selinux

1 Permanent method – need to restart the server

Modify the /etc/selinux/config file to set SELINUX=disabled, and then restart the server.

2 Temporary method – Set system parameters

Use command setenforce 0

Attachment:

setenforce 1 Set SELinux to enforcing mode
setenforce 0 Set SELinux to permissive mode

php’s allow_url_fopen option is turned off

The reason is that the allow_url_fopen option of php is turned off in our php.ini, we just need to turn it on.

If you do not have permission to open allow_url_fopen, we can use the curl function to replace it, which is also a very easy way.

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/632090.htmlTechArticleThis article will introduce to you the solution to the problem that file_get_contents cannot obtain the URL with port. Students who need to know more can refer to it. . Let’s first understand the file_get_contents() function, official introduction...
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template