Home > Backend Development > PHP Tutorial > php function returns instance of multiple values

php function returns instance of multiple values

*文
Release: 2023-03-18 13:46:02
Original
8560 people have browsed it

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


1

2

3

4

5

6

7

8

9

10

<?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";

?>

Copy after login

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!

Related labels:
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
Latest Issues
php data acquisition?
From 1970-01-01 08:00:00
0
0
0
PHP extension intl
From 1970-01-01 08:00:00
0
0
0
How to learn php well
From 1970-01-01 08:00:00
0
0
0
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template