1
0
mirror of https://github.com/restoreddev/phpapprentice.git synced 2025-07-31 12:00:40 +02:00

Initial commit for public repo

This commit is contained in:
Andrew Davis
2018-09-02 10:57:36 -05:00
commit cb5d7c2386
79 changed files with 14644 additions and 0 deletions

26
code/arithmetic.php Normal file
View File

@@ -0,0 +1,26 @@
<?php
// Now that we know how to create variables, let's look at doing some math.
$a = 1;
$b = 2;
// To add two values, use the plus symbol.
$c = $a + $b;
// To subtract, use the minus symbol.
$c = $b - $a;
// To multiply two values, use an asterisk.
echo $a * $b;
// To divide values, use a forward slash.
echo $b / $a;
// PHP uses the percent symbol for calculating the modulus of two numbers.
// The modulus is calculated by dividing two numbers and returning the remainder of the result.
// So, in this example, the value of $modulo will be 0.
$modulo = 10 % 5;
// You can also use double asterisks to calculate a number to the power of another number.
// The following statement will print 25.
echo 5 ** 2;