If you don't understand, why do parameters in methods like exec (), preg_match_all () have output without declaring variables?

for example:

$str = "123123";
preg_match_all("/(\d*)/", $str, $arr);
var_dump($arr);

or:

exec("date", $output);
var_dump($output);

this is not declared $output , and can be output as $arr ? What is the reason for this?

add

<?php
var_dump($res);   // ,

//
function test(&$a){
        $aPP;
}

test($a);
echo $a;   //  1% 
Php
May.12,2021

you can, too.

function fun($a,&$b)
{
    $b = $a;
}
fun(1,$x);
var_dump($x);

Variables in

php do not need to be declared before use, and for output variables that pass addresses, initializes is not necessary if you do not use initial values.

see
http://php.net/manual/en/lang.

Menu