I'm not sure why you asking this since your code clearly demonstrates that it does work. return accepts any expression. The only question might be one of precedence.
Does return $value ? $value : 'none'; mean return ( $value ? $value : 'none' ); or ( return $value ) ? $value : 'none'; ?
If you're not sure of the precedence, a simple test will tell you. (Again, you already did that, so I don't know why you are asking.) Either way, you can state the precedence you desire explicitly using parens.
In reply to Re: Return value in ternary
by ikegami
in thread Return value in ternary
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |