PHP 用switch return 返回值问题

WBOY
Release: 2016-06-23 14:27:50
Original
2151 people have browsed it

switch php library

 public function banben(){

        $this->load->library('LibUser');   
       
        $cc ;
        switch ($this->libuser->getUserType()){
              case 1:
              $cc = $this->libuser->version("a");
              break; 
              case 2:  
              $cc = $this->libuser->version("b");
              case 6:  
              $cc = $this->libuser->version("c");
              break;
              default:
              $cc = "没有数据";
              break;
        }
        return $cc;
    }
----------------------------------------------------
前提我不想用ifelse ,用switch 能不能 return 回去呢?大虾 出来

回复讨论(解决方案)

当然可以啊,你都写好了,测试下不就知道了吗?

当然可以啊,你都写好了,测试下不就知道了吗?
关键我不自信,没有去测试 还以为是错的,现在 测试了通过的

source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template