From 4666e39347bbe647f909744a06422af9d3ff4dbb Mon Sep 17 00:00:00 2001 From: Andrew Davis Date: Wed, 9 Jan 2019 16:56:34 -0600 Subject: [PATCH 1/2] Tweaking home page text and tagline --- assets/templates/_header.phtml | 2 +- assets/templates/index.phtml | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/assets/templates/_header.phtml b/assets/templates/_header.phtml index c8a716d..d6b42a5 100644 --- a/assets/templates/_header.phtml +++ b/assets/templates/_header.phtml @@ -5,7 +5,7 @@ <?= $title ?? 'PHP Apprentice' ?> - + diff --git a/assets/templates/index.phtml b/assets/templates/index.phtml index 9eb8a68..399cf02 100644 --- a/assets/templates/index.phtml +++ b/assets/templates/index.phtml @@ -5,7 +5,7 @@

PHP Apprentice

-

A book for learning how to use PHP

+

An online book for learning PHP

PHP Apprentice is an online, open source book about the PHP programming language. PHP is one of the most popular platforms for building websites and web services. It is a great language that is easy to learn and allows you to build powerful and complex web applications very quickly. @@ -14,7 +14,7 @@ The goal of PHP Apprentice is to be an easy to understand resource for learning how to write good code in PHP. There are a lot of PHP tutorials on the internet that use outdated practices or insecure code. I want this book to show how to write PHP code with quality.

- PHP Apprentice is for beginners and for developers who already know some PHP. The book currently has content for learning the basics of the language. In the future, more pages will be added for more advanced topics like building websites, database integration and security. + The contents of PHP Apprentice are for beginners and experienced PHP developers. The book currently has content for learning the basics of the language. 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. If you would like to give feedback or request a certain discussion topic, check out the GitHub repository. From c57edbe7969adb9b35b105c374e8de22b1d09fc7 Mon Sep 17 00:00:00 2001 From: Andrew Davis Date: Wed, 9 Jan 2019 16:56:52 -0600 Subject: [PATCH 2/2] Chapter editing fixes --- chapters/abstract.md | 2 +- chapters/classes-constructor.md | 5 +++-- chapters/classes-inheritance.md | 4 ++-- chapters/classes.md | 4 ++-- chapters/comparisons.md | 20 ++++++-------------- chapters/conditionals.md | 2 +- chapters/functions.md | 2 +- chapters/interfaces.md | 10 ++++++---- chapters/static.md | 2 +- 9 files changed, 23 insertions(+), 28 deletions(-) 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 {