[wp-hackers] WPMU VHOST constant
Will Anderson
wp-hackers at itsananderson.com
Wed Aug 5 20:00:50 UTC 2009
On Wed, Aug 5, 2009 at 3:40 PM, Aaron D. Campbell <aaron at xavisys.com> wrote:
> If you use constant(), you don't need really need to use defined() since it
> returns null if the constant if undefined. Instead you can just suppress
> the warning, so either of these should work:
> if ( @constant('VHOST') == 'yes' ) {}
> if ( defined('VHOST') && VHOST == 'yes' ) {}
>
> The only edge case where those would perform differently is if you were
> trying to tell if the constant was not defined vs being defined as null:
> //MYCONST purposely not defined
> if ( @constant('MYCONST') == null ) {
> //This runs
> }
> if ( defined('MYCONST') && MYCONST== null ) {
> //This does not run
>
> }
>
Isn't error suppression less efficient though? Once again, I'm not sure it
makes a huge difference in code that will only run once per request, but
it's still probably worth considering.
--
Will Anderson
http://www.itsananderson.com/
More information about the wp-hackers
mailing list