diff --git a/chapters/abstract.md b/chapters/abstract.md index 99b4b6b..4b8d986 100644 --- a/chapters/abstract.md +++ b/chapters/abstract.md @@ -1,6 +1,6 @@ Abstract classes are similar to interfaces in that they define methods that a sub-class must implement. However, an abstract class can also have normal methods. To create an abstract class, use the `abstract` -keyword followed by class and the name of the class. +keyword followed by `class` and the name of the class. ```php unlock(); Lastly, 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(); +$cellPhone = new CellPhone(); // causes an error ``` diff --git a/chapters/arrays.md b/chapters/arrays.md index 5821a02..f1caf9c 100644 --- a/chapters/arrays.md +++ b/chapters/arrays.md @@ -1,7 +1,7 @@ In PHP, arrays are used to store a list of items in a single variable. There are two ways to create an array. -First, you can use the array construct to pass in values separated by commas +First, you can use the `array` construct to pass in values separated by commas and it will return an array. ```php 'Toyota', 'model' => 'Camry']; diff --git a/chapters/classes-constructor.md b/chapters/classes-constructor.md index a81c680..3907bdc 100644 --- a/chapters/classes-constructor.md +++ b/chapters/classes-constructor.md @@ -53,7 +53,7 @@ class Tophat } ``` -`$tophat` now holds an instance of `Tophat`, not the color "Grey". +`$tophat` now holds an instance of `Tophat`, not the string "Grey". ```php $tophat = new Tophat('Grey'); ``` diff --git a/chapters/classes-inheritance.md b/chapters/classes-inheritance.md index d9a5c53..27a6fe5 100644 --- a/chapters/classes-inheritance.md +++ b/chapters/classes-inheritance.md @@ -15,7 +15,7 @@ class Vehicle class Truck extends Vehicle {} ``` -The `Truck` class does not error because `Truck` extends `Vehicle`. +Using the `drive` method on the `Truck` class does not cause an error because `Truck` extends `Vehicle`. ```php $truck = new Truck(); $truck->drive(); diff --git a/chapters/exceptions.md b/chapters/exceptions.md index 9cef6bf..5685542 100644 --- a/chapters/exceptions.md +++ b/chapters/exceptions.md @@ -17,7 +17,7 @@ class Processor In this case, if someone tried to use the `Processor` class to charge a credit card number that is not 16 characters long, an -exception will be thrown which stops the rest of the code from running. +`Exception` will be thrown which stops the rest of the code from running. ```php $processor = new Processor(); $processor->charge('1234'); @@ -26,8 +26,8 @@ $processor->charge('1234'); A developer who wants to prevent an exception from stopping code execution can catch the exception and use it for logging or display the error to a user. -Just wrap the code that might throw an exception with the keyword `try` and brackets -followed by `catch`, the exception type in parentheses and more brackets. +Just wrap the code that might throw an exception with the keyword `try` and braces +followed by `catch`, the exception type in parentheses and more braces. ```php try { $processor->charge('1234'); @@ -47,7 +47,7 @@ Then, you can try to catch your exception instead of the base exception. try { throw new MyCustomException('I am a custom exception'); } catch (MyCustomException $e) { - echo "Cauth MyCustomException\n"; + echo "Caught MyCustomException\n"; } ``` diff --git a/chapters/interfaces.md b/chapters/interfaces.md index 9d72f83..9b198a9 100644 --- a/chapters/interfaces.md +++ b/chapters/interfaces.md @@ -13,7 +13,7 @@ interface Chair ``` To use an interface with a class, you use the `implements` keyword after the class name. -Now, the `Recliner` class must have a `setColor` method and a setLegs method. +Now, the `Recliner` class must have a `setColor` method and a `setLegs` method. If you do not create the required methods on the class, PHP will throw an error. ```php class Recliner implements Chair