diff --git a/chapters/abstract.md b/chapters/abstract.md index 4b8d986..fb11e25 100644 --- a/chapters/abstract.md +++ b/chapters/abstract.md @@ -51,7 +51,7 @@ $android->turnOn(); $android->unlock(); ``` -Lastly, you cannot create an instance of an abstract class. PHP would not know how to use the abstract methods +You cannot create an instance of an abstract class. PHP would not know how to use the abstract methods so when you try to create an abstract instance you will get an error. ```php $cellPhone = new CellPhone(); // causes an error diff --git a/chapters/classes-constructor.md b/chapters/classes-constructor.md index 3907bdc..1ceb9df 100644 --- a/chapters/classes-constructor.md +++ b/chapters/classes-constructor.md @@ -3,7 +3,8 @@ In the previous examples, we always left the parentheses empty. ```php pushPedal(); @@ -71,7 +71,7 @@ class Racecar extends Vehicle } ``` -Outputs "driving..." and "driving even faster...". +The `drive` method on `Racecar` now outputs "driving..." and "driving even faster...". ```php $racecar = new Racecar(); $racecar->drive(); diff --git a/chapters/classes.md b/chapters/classes.md index 8e7fa5e..5c1bd1d 100644 --- a/chapters/classes.md +++ b/chapters/classes.md @@ -25,7 +25,7 @@ class Bicycle ``` Then, when you create an instance of the class, you can set and use -the color attribute on the bicycle using `->`. +the attribute on the instance using `->`. ```php $bike = new Bicycle(); $bike->color = 'Blue'; @@ -55,7 +55,7 @@ class Tricycle } ``` -You can execute a method on an object using the same `->` arrow characters. +You can execute a method on an object using the same `->` arrow characters with parentheses after the method name. ```php $bike = new Tricycle(); $bike->color = 'Red'; diff --git a/chapters/comparisons.md b/chapters/comparisons.md index f29dd11..a514e08 100644 --- a/chapters/comparisons.md +++ b/chapters/comparisons.md @@ -10,32 +10,24 @@ $b = false; There are many constructs and functions that will return a boolean. To start, let's look at comparisons. + +Double equals checks if two values are equal. ```php $one = 1; $two = 2; -``` -Double equals checks if two values are equal. -This statement will return false. -```php -$one == $two; +$one == $two; // returns false ``` An exclamation point and equal sign check if two values are not equal. -This statement will return true. ```php -$one != $two; +$one != $two; // returns true ``` You can use greater than and less than symbols to check for comparisons too. -This statement will return false. ```php -$one > $two; -``` - -This statement will return true. -```php -$one < $two; +$one > $two; // returns false +$one < $two; // returns true ``` If you combine a greater than or less than symbol with an equal, diff --git a/chapters/conditionals.md b/chapters/conditionals.md index 3c28948..0c39227 100644 --- a/chapters/conditionals.md +++ b/chapters/conditionals.md @@ -15,7 +15,7 @@ In the case above, since `$animal` equals 'cow', the statement returns true and An if statement can have multiple conditions chained together. If the first if statement returns false, then PHP will check each `elseif`. -If none of the checks return true, then the else block will be executed. +If none of the checks return true, then the `else` block will be executed. ```php $animal = 'bird'; if ($animal == 'dog') { diff --git a/chapters/functions.md b/chapters/functions.md index 6e6fa85..447d6c0 100644 --- a/chapters/functions.md +++ b/chapters/functions.md @@ -56,7 +56,7 @@ $sum = function ($a, $b) { }; ``` -You can execute a closure by putting parentheses after the variable. +You can execute a closure by putting parentheses after the variable that contains the closure. ```php echo $sum(1, 2) . "\n"; ``` diff --git a/chapters/interfaces.md b/chapters/interfaces.md index 9b198a9..092e367 100644 --- a/chapters/interfaces.md +++ b/chapters/interfaces.md @@ -44,17 +44,19 @@ interface Payment public function charge($amount); } -class CreditCard +class CreditCard implements Payment { public function charge($amount) { - + // contacts a credit card payment provider... } } ``` -Since `CreditCard` implements `Payment`, other developers can use the charge method, knowing it exists on the class. +Since `CreditCard` implements `Payment`, a developer can check that it implements `Payment` and then use the `charge` method knowing the function exists on the class. ```php $creditCard = new CreditCard(); -$creditCard->charge(25); +if ($creditCard instanceof Payment) { + $creditCard->charge(25); +} ``` diff --git a/chapters/static.md b/chapters/static.md index f2b33da..2b847a3 100644 --- a/chapters/static.md +++ b/chapters/static.md @@ -53,7 +53,7 @@ echo $skyscraper->color . "\n"; Often, you will see static constructors in PHP. A static constructor creates a new instance of an object. Why would do that when you can just use "new Class" to create -the object? The most common reason is to make the code more readable. +the object? A common reason is to make the code more readable. ```php class TinyHouse {