dousuiguang9328 2016-05-25 04:42
浏览 162

PHP使用($ _GET ['url'])然后显示json数据?

<?php

function get_stuff()
{
    ($_GET['http://****RemovedForSecurityPurposes****.repairshopr.com/api/v1/tickets?api_key=****RemovedForSecurityPurposes****']);
    echo $_GET;
}

get_stuff();

?> /* Yes, Pointless closing tag, I'm cool like that. */

For some reason when I run this code the output I'm getting is "Array" and I can't figure out why? I know it is an array that I'm getting from the URL but I thought it would just print in whatever format its in? Am I missing something?

Thanks In advance!

  • 写回答

2条回答 默认 最新

  • dsxgby126001 2016-05-25 04:49
    关注

    The Message of OP when I run this code the output I'm getting is "Array".

    You need to use file_get_contents to read a file from a remote server. If your file response an array then you have to use print_r or var_export or var_dump. Or if your file response is a string(json) then you need to store it in a variable and apply a decode method.

    function get_stuff(){
        $response = file_get_contents('http://****RemovedForSecurityPurposes****.repairshopr.com/api/v1/tickets?api_key=****RemovedForSecurityPurposes****');
        print_r($response); // if array
        $arr = json_decode($response); // decode of json
        print_r($arr);
    }
    
    get_stuff();
    

    I think you will understand what i mean. Let me know if you are useful or need some help.

    评论

报告相同问题?

悬赏问题

  • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
  • ¥15 CSAPPattacklab
  • ¥15 一直显示正在等待HID—ISP
  • ¥15 Python turtle 画图
  • ¥15 关于大棚监测的pcb板设计
  • ¥15 stm32开发clion时遇到的编译问题
  • ¥15 lna设计 源简并电感型共源放大器
  • ¥15 如何用Labview在myRIO上做LCD显示?(语言-开发语言)
  • ¥15 Vue3地图和异步函数使用
  • ¥15 C++ yoloV5改写遇到的问题