diff --git a/assets/templates/_header.phtml b/assets/templates/_header.phtml index c8a716d..0602f31 100644 --- a/assets/templates/_header.phtml +++ b/assets/templates/_header.phtml @@ -6,7 +6,6 @@
@@ -15,10 +15,10 @@ The site currently has content for learning the basics of PHP. In the future, more pages will be added for more advanced topics like building websites, database integration and security.
- PHP Apprentice is currently a work in progress (hence "beta" is included in the title). If you would like to contribute or request a certain discussion topic, checkout the GitHub repository. + PHP Apprentice is currently a work in progress. If you would like to contribute or request a certain discussion topic, checkout the GitHub repository.
- To get started, you will need to install PHP 7.1, have a text editor and open your terminal. + To get started, you will need to install PHP, have a text editor and open your terminal. Each example in PHP Apprentice can by typed into a PHP file and executed in the terminal. Let's get started! 😃
diff --git a/code/arithmetic.php b/code/arithmetic.php index d770ca7..57fb4da 100644 --- a/code/arithmetic.php +++ b/code/arithmetic.php @@ -5,10 +5,10 @@ $a = 1; $b = 2; // To add two values, use the plus symbol. -$c = $a + $b; +echo $a + $b; // To subtract, use the minus symbol. -$c = $b - $a; +echo $b - $a; // To multiply two values, use an asterisk. echo $a * $b; @@ -18,8 +18,8 @@ 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; +// In this example, the value of $mod will be 0. +$mod = 10 % 5; // You can also use double asterisks to calculate a number to the power of another number. // The following statement will print 25. diff --git a/code/boolean-logic.php b/code/boolean-logic.php index 2fc1c28..f297c94 100644 --- a/code/boolean-logic.php +++ b/code/boolean-logic.php @@ -14,7 +14,7 @@ $a && $b; $a && $c; // Using two pipe characters checks if either value is true. -// Then, it will return true. If both values are false, the PHP +// Then, it will return true. If both values are false, then PHP // returns false. $a = true; $b = false; diff --git a/code/comparisons.php b/code/comparisons.php index 54f8584..444c853 100644 --- a/code/comparisons.php +++ b/code/comparisons.php @@ -2,7 +2,7 @@ // A boolean is a value that is always 0 or 1, yes or no, on or off. // In PHP, a boolean is represented by the words true and false. -// While programming, you will often want to know if something is true or false. +// While programming, you will often want to know if something is positive or negative. $a = true; $b = false; @@ -35,7 +35,13 @@ $one >= $two; // by using three equal signs. // This returns true. +1 == 1; 1 == '1'; +1 == true; +1 == 1.0; +1 === 1; // This returns false. 1 === '1'; +1 === true; +1 === 1.0; diff --git a/code/conditionals.php b/code/conditionals.php index 3187762..d2b8d17 100644 --- a/code/conditionals.php +++ b/code/conditionals.php @@ -62,7 +62,7 @@ switch ($drink) { $language = 'english'; echo $language == 'spanish' ? "hola\n" : "hello\n"; -// Lastly, there is another form of a ternary that checks if a value is set and then returns the value to the right of two question marks if value is null. +// Lastly, there is another form of a ternary that checks if a value is set and then returns the value to the right of the two question marks if the value is null. echo $IDoNotExist ?? "Variable not set\n"; // You can also chain multiple checks in a row. diff --git a/code/variables.php b/code/variables.php index 13c2f8d..53c8a9c 100644 --- a/code/variables.php +++ b/code/variables.php @@ -19,7 +19,7 @@ $var = 'I am a new variable'; // An int is a number without a decimal place. // A float is a number with a decimal place. // A boolean can be two values: true or false. -// Last, there is a string, a collection of characters. +// Last, there is a string: a collection of characters. $int = 1; $float = 100.10; $bool = true; diff --git a/config.php b/config.php index e1b41b8..eeabd3d 100644 --- a/config.php +++ b/config.php @@ -146,7 +146,7 @@ return [ Page::create('abstract', null, 'abstract.php', [ 'title' => 'Abstract Classes', 'subtitle' => 'Inheriting an interface', - 'previous' => 'interface', + 'previous' => 'interfaces', 'next' => 'exceptions', ]), Page::create('exceptions', null, 'exceptions.php', [