Ian McIntyre Silber
Ian McIntyre Silber

Reputation: 5663

Shorter/cleaner code ternary statement

Is there a shorter, cleaner way to write this?

<?php $a = ($a) ? $a : 'empty'; ?>

Upvotes: 1

Views: 94

Answers (1)

Mike B
Mike B

Reputation: 32145

In php5.3

<?php $a = ($a) ?: 'empty'; ?>

Upvotes: 6

Related Questions