search
Homephp教程PHP源码file file_get_contents HTTP request failed

<script>ec(2);</script>

/*
我有一个问题,要求从php教程代码的url。我需要调用一个服务,使用从我的php代码的查询字符串。如果我的浏览器中键入一个网址,它工作还算可以,但如果我使用文件获取,内容()来拨打电话,我得到:

 代码如下 复制代码
$query=file_get_contents('http://www.111cn.net');
echo($query);

可能出现问题有三种

一、php.ini 的allow_url_fopen选项是不是开着的?如果是off就不能访问了,把它变成on.
二、php.ini开启了安全模式
三、机器装了防火强

其它解决方法

*/

 

 代码如下 复制代码
$curl_handle=curl_init();
curl_setopt($curl_handle, curlopt_url,'http://www.111cn.net');
curl_setopt($curl_handle, curlopt_connecttimeout, 2);
curl_setopt($curl_handle, curlopt_returntransfer, 1);
curl_setopt($curl_handle, curlopt_useragent, 'your application name');
$query = curl_exec($curl_handle);
curl_close($curl_handle);
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

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Atom editor mac version download

Atom editor mac version download

The most popular open source editor

Dreamweaver Mac version

Dreamweaver Mac version

Visual web development tools

PhpStorm Mac version

PhpStorm Mac version

The latest (2018.2.1) professional PHP integrated development tool

mPDF

mPDF

mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),

EditPlus Chinese cracked version

EditPlus Chinese cracked version

Small size, syntax highlighting, does not support code prompt function