docs(examples): add return multi values example for PHP

- Create foo function that returns array with multiple values
- Implement array destructuring assignment in main function
- Add php_uname call to demonstrate system information output
- Show usage of spread operator for variable assignment
pull/20/head
韩天峰 1 month ago
parent 8be62dafb3
commit fa7e2cf7c1
  1. 15
      examples/return-multi-values.php

@ -0,0 +1,15 @@
<?php
function foo(): array {
$a = 1;
$b = 2;
$c = 3;
return [$a, $b, $c];
}
function main()
{
var_dump(php_uname());
[$a, $b, $c] = foo();
var_dump($a, $b, $c);
}
Loading…
Cancel
Save