Ask about general coding issues or problems here.
Moderators: macek, egami, gesf
I am new to php developing but so far have been able to do whatever I want. I recently came across a strange syntax of writing a return statement:
- Code: Select all
public static function return_taxonomy_field_value( $value )
return (! empty(self::$settings['tax_value']) ) ? self::$settings['tax_value'] : $value;
I get the return() and the !empty() but after that it has a ? and that's where I get lost. Any help is much appreciated! Thanks guys
- New php-forum User
- Posts: 1
- Joined: Mon Mar 24, 2014 6:32 am
that's whats called a ternary comparison. a boolean expression is evaluated and different responses are given depending on whether it's true or false.
in this case, the objects tax value which is stored in the settings is evaluated to make sure that it has a value greater than 0. if it doesn, that value is returned otherwise the value stored in $value is returned instead.
- php-forum Fan User
- Posts: 838
- Joined: Mon Oct 01, 2012 12:32 pm
Return to PHP coding => General
Who is online
Users browsing this forum: No registered users and 1 guest