简体   繁体   English

如果是,则为检查PHP的真实条件

[英]if else true condition to check in PHP

i want a simple simply check if the json file contains latest in the beganing than it should do some function, if the json file contains videos in the beganing than it should do some other functions. 我想要一个简单的只是检查JSON文件包含beganing 最新的比它应该做的一些功能,如果JSON文件包含了比它应该做一些其他的功能beganing 视频 This is my PHP code --- 这是我的PHP代码-

$url = 'http://www.hello.se/3209406a5d0f95&limit=15';
$json = json_decode(file_get_contents($url), true);

if($json['latest']['videos']){ // how can i just put a condition where if it is true than 
//do some function or if it is not true go to the next condition which is else if($json['videos']){ ...

        // do some functions
       }
else if($json['videos']){
// do some functions

i have also tried like so ---- 我也曾尝试过----

$url = 'http://www.hello.se/3209406a5d0f95&limit=15';
$json = json_decode(file_get_contents($url), true);

if($json['latest']['videos'] === true){

        // do some functions
       }
else if($json['videos'] === true){
// do some functions

which is not working for me, can anyone help me to fix this issue. 这对我不起作用,任何人都可以帮助我解决此问题。 Any advice will be really appreciate, thanks in advanced. 任何建议将不胜感激,谢谢。

use isset() : http://php.net/manual/en/function.isset.php 使用isset()http : //php.net/manual/en/function.isset.php

if(isset($json['latest']['videos'])){ // how can i just put a condition where if it is true than 
//do some function or if it is not true go to the next condition which is else if($json['videos']){ ...

        // do some functions
       }
else if(isset($json['videos'])){
// do some functions

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM