Function behaves differently depending on how called

I have a function

function foo($a, $b) {

$b = ‘somethingNew’

#do some stuff

return $b


if i run

foo ‘thing1’ ‘thing2’ all things work fine

if i run

$ret = $foo ‘thing1’ ‘thing2’

the function doesn’t work the same and the stuff inside doesn’t work

what am i missing


Is the typo only here or is it in your code? It should be $ret = foo ‘thing1’ ‘thing2’ and not $ret = $foo ‘thing1’ ‘thing2’