search
Homephp教程php手册判断返回类型解决思路

判断返回类型解决思路

Jun 06, 2016 pm 07:43 PM
healthjudgmentIdeastypesolvereturn

判断返回类型 if(\Health\ArticleChannel::addChannel($name,$re,$status,$order)) { self::output(['title'='添加成功','type'='success']); } else { self::output(['title'='添加失败','type'='error']); } array(2){ ["status"]= bool(false) ["msg"]= st

判断返回类型
if (\Health\ArticleChannel::addChannel($name,$re,$status,$order))<br />
			{<br />
				self::output(['title'=>'添加成功','type'=>'success']);<br />
			}<br />
			else<br />
			{<br />
				self::output(['title'=>'添加失败','type'=>'error']);<br />
			}<br />
<br />
                array(2) {<br />
                ["status"]=><br />
                bool(false)<br />
                 ["msg"]=><br />
                string(15) ""<br />
}<br />
这种返回类型怎么判断?<br />
<br />
</p【本文来自鸿网互联 (http://www.68idc.cn)】re><br><font color='#FF8000'>------解决思路----------------------</font><br><pre class="brush: php">            if(is_bool($arr['status'])){<br />
            	echo "是布尔类型";<br />
            }<br />
            if(is_string($arr['msg'])){<br />
            	echo "是字符串类型";<br />
            }

------解决思路----------------------
引用:
Quote: 引用:

如果返回bool就是false  true
这里是什么意思? 没看懂。详细描述一下。


现在就是这样的.
我判断他的类型.  返回成功和失败.

如果一个返回值是bool型的话  那他返回不就是ture跟false吗?   我想问的是我那个if怎么判断.我用var_dump打印出来类型了.  三种我就不知道if怎么写了.

一般的语句都是  if(isset($a))    if(empty($a))  if($a  !==false)    对不对...我就想知道我这个if怎么写




你想问的是三种情况的if条件的写法么?
if(is_bool($arr['status'])){
      echo  "bool型";
}elseif(is_string($arr['msg'])){
    echo  "字符串型";
}else{
 echo  "其他类型";
}

------解决思路----------------------
是否boolean
is_bool();

是否string
is_string();

是否数组
is_array();
Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

MantisBT

MantisBT

Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

Dreamweaver Mac version

Dreamweaver Mac version

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

PhpStorm Mac version

PhpStorm Mac version

The latest (2018.2.1) professional PHP integrated development tool

WebStorm Mac version

WebStorm Mac version

Useful JavaScript development tools