I'm planning to use PHP for a simple requirement. I need to download a XML content from a URL, for which I need to send HTTP GET request to that URL.

How do I do it in PHP?

推荐答案

Unless you need more than just the contents of the file, you could use file_get_contents.

$xml = file_get_contents("http://www.example.com/file.xml");

For anything more complex, I'd use cURL.

Php相关问答推荐

在WooCommerce管理订单页面中显示区域名称

如何修复警告:当使用WordPress get_the_Terms()时,Foreach()参数必须是ARRAY|OBJECT类型?

WooCommerce数量减号和加号图标未显示

Laravel eloquent-如果没有包含InitialValue的结果,则查询where Second Value

如何在Livewire 3 Form类中做依赖注入?

Symfony Validator:如何使用XML表示法验证深度嵌套的数据?

PHP SimpleXML:按属性值访问 node

用GUZLE模拟Read_Timeout

在WooCommerce Admin产品列表自定义列中显示来自元数据的统计数据

获取作者';在WordPress中使用PHP

将自定义字段添加到管理产品 在 WooCommerce 3.2+ 中批量编辑

批量更新 WooCommerce 中所有产品的特定自定义字段

在 WooCommerce wc_get_products 函数中处理自定义分类法

从图像URL中获取文件扩展名?

正则表达式请帮我从内容中找到这个词

同时执行odbc_execute、odbc_fetch_row和odbc_result

在 DomPDF 和 Laravel 中使用内联 css

如何在 Laravel 中验证多个输入?

复杂的mysql查询问题

getenv() 有时在 CodeIgniter 4 中返回 false.为什么?