duanjing9739 2016-08-05 20:45
浏览 48
已采纳

PHP获取另一个php页面的内容

I've got a webpage that display this : http://i.imgur.com/QUkMoiC.jpg Just plain text. And I need to include this in another php webpage, like

$string = include('http://77.144.233.158:4032/currentsong?sid=1');
echo $string;

so this can return "King crimson - Moonchild - Lyrics". but this doesn't work.

How can I do ?

  • 写回答

1条回答 默认 最新

  • dqwh1201 2016-08-05 20:46
    关注

    Include will evaluate what's inside the specified file (And run it as PHP). For example, if you had:

    $str = 'King crimson - Moonchild - Lyrics';
    

    You could include it, and then echo $str to get what you are looking for.

    I think what you're looking for is file_get_contents():

    $string = file_get_contents('http://77.144.233.158:4032/currentsong?sid=1');
    echo $string;
    

    From the docs:

    file_get_contents() is the preferred way to read the contents of a file into a string. It will use memory mapping techniques if supported by your OS to enhance performance.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 基于单片机的靶位控制系统
  • ¥15 AT89C51控制8位八段数码管显示时钟。
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 下图接收小电路,谁知道原理
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度
  • ¥30 关于#r语言#的问题:如何对R语言中mfgarch包中构建的garch-midas模型进行样本内长期波动率预测和样本外长期波动率预测
  • ¥15 ETLCloud 处理json多层级问题
  • ¥15 matlab中使用gurobi时报错