php_variables
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
php_variables [2024/10/06 05:12] – appledog | php_variables [2024/10/06 05:16] (current) – appledog | ||
---|---|---|---|
Line 20: | Line 20: | ||
</ | </ | ||
- | === Integers | + | == Operations |
- | We can also store numbers. | + | We can add variables together. |
+ | |||
+ | < | ||
+ | <?php | ||
+ | |||
+ | $a = readLine(" | ||
+ | $b = readLine(" | ||
+ | |||
+ | echo $a . " + " . $b . " = " . $a+$b . " | ||
+ | |||
+ | ?> | ||
+ | </ | ||
+ | |||
+ | |||
+ | == Testing variables with IF | ||
+ | We can also determine what to do based on what's in a variable. | ||
+ | |||
+ | < | ||
+ | <?php | ||
+ | |||
+ | $name = readLine(" | ||
+ | $fruit = readLine(" | ||
+ | |||
+ | if ($fruit == " | ||
+ | echo " | ||
+ | echo $name . " is bad!\n"; | ||
+ | } else if ($fruit == " | ||
+ | echo " | ||
+ | echo "I also like {$fruit}. Yum!\n"; | ||
+ | } else { | ||
+ | echo " | ||
+ | } | ||
+ | |||
+ | ?> | ||
+ | </ | ||
+ | |||
+ | |||
+ | == Integers | ||
+ | We can also store numbers and do operations on those numbers. | ||
< | < | ||
Line 34: | Line 72: | ||
?> | ?> | ||
</ | </ | ||
+ |
php_variables.1728191565.txt.gz · Last modified: 2024/10/06 05:12 by appledog