方法1:
用file_get_contents 以get方式获取内容
[php] view plaincopyprint? <?php $url='http://www.domain.com/'; $html = file_get_contents($url); echo $html; ?>
方法2:
用fopen打开url, 以get方式获取内容
[php] view plaincopyprint? <?php $fp = fopen($url, 'r'); //返回请求流信息(数组:请求状态,阻塞,返回值是否为空,返回值http头等) [php] view plaincopyprint? stream_get_meta_data($fp); [php] view plaincopyprint? while(!feof($fp)) {
推荐教程:
立即学习“PHP免费学习笔记(深入)”;
以上就是php怎么循环请求接口的详细内容,更多请关注php中文网其它相关文章!
PHP怎么学习?PHP怎么入门?PHP在哪学?PHP怎么学才快?不用担心,这里为大家提供了PHP速学教程(入门到精通),有需要的小伙伴保存下载就能学习啦!
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号