Home > Backend Development > PHP Tutorial > php中实现可以返回多个值的函数实例_PHP

php中实现可以返回多个值的函数实例_PHP

WBOY
Release: 2016-05-31 11:45:21
Original
821 people have browsed it

本文实例讲述了php中实现可以返回多个值的函数用法。分享给大家供大家参考。具体分析如下:

在python和golang中都有一个函数同时返回多个值的方法,其实php也可以,但相比python和golang要稍微麻烦一点,下面是一个简单的演示范例,这里用到了list函数

<&#63;php
  function retrieve_user_profile() {
   $user[] = "Jason";
   $user[] = "jb51.net";
   $user[] = "English";
   return $user;
  }
  list($name,$email,$language) = retrieve_user_profile();
  echo "Name: $name, email: $email, preferred language: $language";
&#63;>
Copy after login

希望本文所述对大家的php程序设计有所帮助。

Related labels:
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