When running the following code:
<?php
$output = array();
exec("ping google.com", &$output);
foreach ($output as $key => $value) {
echo $value . "<br/>";
}
?>
Getting Deprecated: as follows
Call-time pass-by-reference has been deprecated in C:\xampp\htdocs\my_test\ajax_loop.php on line 3.
Please help.
You need to drop the reference operator from
&$outputindeed.Few tutorials provides the syntax of functions as follows (exec in this example).
The ‘&’ is not a reference operator, it only indicates that they are output variables, meaning you can expect the values of these variables to be populated with output data after the function call.
In this case after the function call the
$outputarray will be filled with all lines of output from the commnad which you try to execute. The$return_varwill have the return status.