Home >Backend Development >PHP Tutorial >Implement a function instance that can return multiple values in php, php example_PHP tutorial
The examples in this article describe the usage of functions that can be implemented in php that can return multiple values. Share it with everyone for your reference. The specific analysis is as follows:
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. Here is a simple demonstration example, where the list function is used
<?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"; ?>
I hope this article will be helpful to everyone’s PHP programming design.