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

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.

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

报告相同问题?

悬赏问题

  • ¥20 iOS绕地区网络检测
  • ¥15 python验证码滑块图像识别
  • ¥15 根据背景及设计要求撰写设计报告
  • ¥15 QT6颜色选择对话框显示不完整
  • ¥20 能提供一下思路或者代码吗
  • ¥15 用twincat控制!
  • ¥15 请问一下这个运行结果是怎么来的
  • ¥15 单通道放大电路的工作原理
  • ¥30 YOLO检测微调结果p为1
  • ¥15 DS18B20内部ADC模数转换器