How would you do this in php? As far as I know, and unless the php docs are out of date, you cannot
PHP: Returning values - Manual


In java you could effectively do this just as you would in php...