【背景】
折腾:
【已解决】PHP中的json的json_decode不工作没有任何输出
期间,需要搞懂一个:
curl_exec 返回的变量$respJson的类型是什么,是不是string类型。
【折腾过程】
1.搜:
php check variable type
参考:
所以去试试:
1 2 3 4 5 6 | $respJson = $crifanLib ->getUrlRespHtml( $getTokenUrl ); $crifanLib ->logWrite( "respJson=%s" , $respJson ); echo gettype ( $respJson ); echo is_string ( $respJson ); echo "before decodedJsonObj" ; $decodedJsonObj = json_decode( $respJson ); |
结果:
还是没有任何输出。。。
2.试试:
1 2 | echo gettype ( $respJson ); echo is_string ( $respJson ); |
结果:
输出:string1
那就证明,此处的变量的类型的确是string的。
【总结】
PHP中获得变量类型是gettype($var);
单独判断是某种类型,可以用:
is_int
is_string
等等。
转载请注明:在路上 » 【已解决】PHP如何查看当前变量的类型