Difference between revisions of "PHP 2"
From Ilianko
Line 3: | Line 3: | ||
Условни оператори | Условни оператори | ||
− | $myVar = 1; | + | $myVar = 1; |
− | $myZero = 0; | + | $myZero = 0; |
− | $myString = 'ilian'; | + | $myString = 'ilian'; |
− | $myZeroString = ''; | + | $myZeroString = ''; |
− | |||
− | |||
− | |||
− | |||
− | |||
+ | //var_dump( $myZero = $myVar ); | ||
+ | //var_dump( $myVar = $myZero ); | ||
+ | //var_dump( $myZero = $myString ); | ||
+ | |||
+ | //var_dump( $myZero == $myVar ); | ||
+ | //var_dump( $myZero == $myString ); | ||
+ | //var_dump( $my == $myZeroString ); | ||
+ | |||
+ | //var_dump( $myVar === $myString ); | ||
+ | //var_dump( $myVar === $myZeroString ); | ||
+ | //var_dump( $myVar == $myString ); | ||
+ | //var_dump( $myZeroString == $myVar ); | ||
+ | //var_dump( $myZeroString == $myZero ); | ||
+ | //var_dump( $myZeroString == $myString ); | ||
+ | |||
+ | //var_dump( $myZeroString === $myString ); | ||
+ | //var_dump( $myZeroString === $myVar ); | ||
+ | //var_dump( $myZeroString === $myZero ); | ||
+ | //var_dump( $myString === $myZero ); | ||
== if == | == if == | ||
Line 50: | Line 64: | ||
$text = 'Please register | $text = 'Please register | ||
− | echo $text.'Click Next'; | + | echo $text.' Click Next'; |
+ | |||
+ | === () ? : === | ||
− | === ? | + | $text = ($myVar == 'logged') ? 'You are logged' : 'Please login'; |
+ | echo $text.' Click Next'; | ||
Revision as of 09:54, 20 October 2013
Условни оператори
$myVar = 1; $myZero = 0; $myString = 'ilian'; $myZeroString = ;
//var_dump( $myZero = $myVar ); //var_dump( $myVar = $myZero ); //var_dump( $myZero = $myString ); //var_dump( $myZero == $myVar ); //var_dump( $myZero == $myString ); //var_dump( $my == $myZeroString ); //var_dump( $myVar === $myString ); //var_dump( $myVar === $myZeroString ); //var_dump( $myVar == $myString ); //var_dump( $myZeroString == $myVar ); //var_dump( $myZeroString == $myZero ); //var_dump( $myZeroString == $myString ); //var_dump( $myZeroString === $myString ); //var_dump( $myZeroString === $myVar ); //var_dump( $myZeroString === $myZero ); //var_dump( $myString === $myZero );
Contents
if
if
$myVar = 'Ivan';
if($myVar == 'logged'){ echo 'You are logged'; }
echo 'Click Next';
if else
$myVar = 'Ivan';
if($myVar == 'logged'){ echo 'You are logged'; } else { echo 'Please login'; }
echo 'Click Next';
if elseif else
if($myVar == 'logged'){ $text = 'You are logged'; } elseif($myVar == 'guest') { $text = 'Please choose name'; } else $text = 'Please register
echo $text.' Click Next';
() ? :
$text = ($myVar == 'logged') ? 'You are logged' : 'Please login'; echo $text.' Click Next';