Shorthand PHP code
-
Is shorthand PHP like the below acceptable coding standards for WordPress?
$title = $fields[‘title’] ?? ”;
In the WordPress PHP coding standards, it only talks about shorthand PHP tags not being acceptable.
Any info would be appreciated.
The blog I need help with is: (visible only to logged in users)
-
Shorthand PHP isn’t supported as very clearly stated – https://developer.wordpress.org/coding-standards/wordpress-coding-standards/php/
-
Thanks for the reply, but as stated in my first post, this just talks about shorthand tags, nothing about shorthand code
-
Ah, yes, the use of the ternary operator to shorthand if conditionals. Yes, that is allowed, provided they test whether the statement is true, not false. More details on the use of the ternary operator in the WPCS docs: https://developer.wordpress.org/coding-standards/wordpress-coding-standards/php/#ternary-operator
- The topic ‘Shorthand PHP code’ is closed to new replies.