File_get_contents cannot obtain the URL with Port

Source: Internet
Author: User


First, let's take a look at the file_get_contents () function. The official introduction says it reads the entire file into a string.


Example

<? Php
Echo file_get_contents ("test.txt ");
?>

Output:

This is a test file with test text.

This function can also be used to obtain the content on the remote server.


File_get_contents ('http: // www.111cn.net ');

This is no problem, but if I bring the port, it will be a problem.


For example:


File_get_contents ('http: // localhost: 100 ');


There is no get.

Solution: disable selinux.

1 Permanent method-server restart required

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

2. Temporary method-set system parameters

Run the setenforce 0 command.

Appendix:

Setenforce 1 sets SELinux to enforcing mode
Setenforce 0 sets SELinux to permissive mode

Php's allow_url_fopen option is disabled.

The reason is that the allow_url_fopen option of php is disabled in php. ini. We just need to open it.

If you do not have the permission to open allow_url_fopen, we can use the curl function to replace it.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.