如何在函数中添加变量

时间:2018-04-03 17:26:48

标签: php function

如何在函数中添加变量数据

$accesToken = "EAAAAUaZA8jlABAOoCy9Wy..........";
    $fields = "fields=title,length,from,description,created_time,source";  
    function facebook(){
         $json_array = file_get_contents("https://graph.facebook.com/v2.12/$PID[$FID]/videos?{$fields}&limit=10&access_token={$accesToken}");   
    }

请解决这个正确的代码

1 个答案:

答案 0 :(得分:0)

  $AccessToken = "EAAAAUaZA8jlABAOoCy9Wy58ONRie2TwU697ajMboXCx0OIAe1a8r0E89NN6ZCNRLWMzHgEbhaDVMpYqXiW42aixSjajwGVV1BJM26IIuNkZALrN2NBvFt0fxgmqCYvniZAMEO2SY7v6CstT3OECtDjwBVnku4OgZD";

  function video(){

      global $AccessToken;

        $json_array = file_get_contents("https://graph.facebook.com/v2.12/456898118003430/videos?fields=title,length,from,description,created_time,source&limit=10&access_token=$AccessToken");

    $json_data=json_decode($json_array,true);

   echo "<pre>";

   print_r($json_data);

  }

 video();