functionTypes - PHP Online
Form of PHP Sandbox
Enter Your PHP code here for testing/debugging in the Online PHP Sandbox. As in the usual PHP files, you can also add HTML, but do not forget to add the tag <?php
in the places where the PHP script should be executed.
Result of php executing
Full code of functionTypes.php
- <?php
- function copyValue(array $arr) {
- $arr[] = 2;
- }
- function returnValue(array $arr): array {
- $arr[] = 3;
- return $arr;
- }
- function referenceValue(array &$arr) {
- $arr[] = 4;
- }
- $array1 = [1];
- copyValue($array1); //bleibt [1]
- $array1 = returnValue($array1); //wird [1,3]
- referenceValue($array1); //wird [1,3,4]
- var_dump($array1);