Home > Backend Development > PHP Tutorial > Implement a function that can return multiple values ​​in php

Implement a function that can return multiple values ​​in php

WBOY
Release: 2016-07-25 08:43:35
Original
886 people have browsed it

There is a method in python and golang for a function to return multiple values ​​at the same time. In fact, php can also do it, but it is a little more troublesome than python and golang. Here is a simple demonstration example, the list function is used here

  1. function retrieve_user_profile() {
  2. $user[] = "Jason";
  3. $user[] = "sharejs.com";
  4. $user[] = "English";
  5. return $user;
  6. }
  7. list($name,$email,$language) = retrieve_user_profile();
  8. echo "Name: $name, email: $email, preferred language: $language";
  9. ?>
Copy code

Multiple, php


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