Im using a WordPress transient, which expires after an hour, to store a value which is an integer. Im trying to use switch()
and multiple case()
statements to evaluate if the transient exists or not (i.e true or false).
Here are my questions:
- Which comparison operator (
=
,==
,===
), in example 2, is ideal for this context? - Which of the following examples is appropriate?
- Would the following examples yield the same result?
Example 1:
$transient = get_transient( 'foobar' );
switch( $transient ) :
case( true ) :
// do stuff
break;
case( false ) :
// do stuff
break;
endswitch;
versus
Example 2:
$transient = get_transient( foobar );
switch( $transient ) :
case( $transient = true ) :
// do stuff
break;
case( $transient = false ) :
// do stuff
break;
endswitch;
Thanks in advance.