I have the following inside a function something():
if ($cod == 1000)
{
$message = 'Some Message';
return $message;
}
Later, I call this function:
try
{
$comandoController->someThing();
}
I was expecting to see "Some Message" on th开发者_StackOverflowe browser. But I don't.
Note: If I echo
something like echo "hello"
inside the conditional, I can see it. So the condition is the case.
Instead of $comandoController->someThing();
should we do the following:
$result = $comandoController->someThing();
echo $result;
Works as designed. This
try
{
$comandoController->someThing();
}
will not output anything to the browser. The return value can be echo
ed:
echo $comandoController->someThing();
or stored:
$value = $comandoController->someThing();
but as it stands, no browser output will take place.
You need to echo
that:
echo $comandoController->someThing();
Or use the echo
inside your function instead:
if ($cod == 1000)
{
echo 'Some Message';
}
Now you simply need to do:
$comandoController->someThing();
精彩评论