【问题标题】:Trying to define GLOBAL variable not working PHP试图定义 GLOBAL 变量不起作用 PHP
【发布时间】:2015-01-13 19:12:43
【问题描述】:

你好,我试图为不同的函数定义一个全局变量,但我不断得到 无法打开流,我就是找不到问题所在。 你能帮我找出我做错了什么吗?

谢谢!

<?php
 $feedURL = "http://gdata.youtube.com/feeds/api/users/ArrolladoraLimonVEVO?alt=json";


function GetytTitle() {
    global $feedURL;
    $json = file_get_contents ('feedURL');
    $obj = json_decode($json,true);
    return $obj['entry']['title']['$t'];
}
 ?>         

【问题讨论】:

    标签: php variables global-variables


    【解决方案1】:

    你没有使用你的变量:

     $json = file_get_contents ('feedURL');
    

    应该是:

     $json = file_get_contents ($feedURL);
    

    现在file_get_contents 正在您的脚本目录中寻找一个名为feedURL 的文件。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多