Home  >  Article  >  Backend Development  >  php function returns instance of multiple values

php function returns instance of multiple values

*文
*文Original
2017-12-26 10:54:188411browse

How does a php function return multiple values? This article mainly introduces the implementation of functions in PHP that can return multiple values, and analyzes the techniques of PHP using arrays to return multiple values. I hope to be helpful.


In python and golang, there is a method 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. The following is A simple demonstration example, the list function is used here


<?php
  function retrieve_user_profile() {
   $user[] = "Jason";
   $user[] = "php.cn";
   $user[] = "English";
   return $user;
  }
  list($name,$email,$language) = retrieve_user_profile();
  echo "Name: $name, email: $email, preferred language: $language";
?>

Related recommendations:

PHP function Note

Introduction to PHP function syntax 1_PHP tutorial

Simple summary of PHP function learning _PHP Tutorial

The above is the detailed content of php function returns instance of multiple values. For more information, please follow other related articles on the PHP Chinese website!

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