Reputation: 1550
I am trying to return multiple variables in a function to another php page.
I looked at other sources but I can't get it to work. What am I doing wrong here?
function byRef($value1, &$value2, &$value3){
global $value1, $value2, $value3;
string.$value1 = "Hello";
string.$value2 = "World";
string.$value3 = " ";
string.$value3 .= $value1 . $value2 ;
}
byRef($value1, $value2, $value3);
echo $value3;
Help is appreciated
Upvotes: 0
Views: 252
Reputation: 2494
Don't use global, it imports the variables that are not in the function.
Don't use that string. something either. I don't know what it is or if it exists, but don't use it.
<?php
$value1 = 'not hello';
function byRef($value1, &$value2, &$value3){
$value1 = "Hello";
$value2 = "World";
$value3 = " ";
$value3 .= $value1 . $value2 ;
}
byRef($value1, $value2, $value3);
echo $value3;
Upvotes: 1