Skip to content

Commit c166410

Browse files
authored
Merge branch 'codeguy:gh-pages' into gh-pages
2 parents 8b934a2 + af42290 commit c166410

File tree

5 files changed

+7
-17
lines changed

5 files changed

+7
-17
lines changed

_posts/03-05-01-Command-Line-Interface.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,11 @@ Let's write a simple "Hello, $name" CLI program. To try it out, create a file na
2727
{% highlight php %}
2828
<?php
2929
if ($argc !== 2) {
30-
echo "Usage: php hello.php <name>.\n";
30+
echo "Usage: php hello.php <name>" . PHP_EOL;
3131
exit(1);
3232
}
3333
$name = $argv[1];
34-
echo "Hello, $name\n";
34+
echo "Hello, $name" . PHP_EOL;
3535
{% endhighlight %}
3636

3737
PHP sets up two special variables based on the arguments your script is run with. [`$argc`][argc] is an integer

_posts/05-03-01-Date-and-Time.md

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ output.
1919
$raw = '22. 11. 1968';
2020
$start = DateTime::createFromFormat('d. m. Y', $raw);
2121
22-
echo 'Start date: ' . $start->format('Y-m-d') . "\n";
22+
echo 'Start date: ' . $start->format('Y-m-d') . PHP_EOL;
2323
{% endhighlight %}
2424

2525
Calculating with DateTime is possible with the DateInterval class. DateTime has methods like `add()` and `sub()` that
@@ -34,7 +34,7 @@ $end = clone $start;
3434
$end->add(new DateInterval('P1M6D'));
3535

3636
$diff = $end->diff($start);
37-
echo 'Difference: ' . $diff->format('%m month, %d days (total: %a days)') . "\n";
37+
echo 'Difference: ' . $diff->format('%m month, %d days (total: %a days)') . PHP_EOL;
3838
// Difference: 1 month, 6 days (total: 37 days)
3939
{% endhighlight %}
4040

@@ -43,8 +43,7 @@ You can use standard comparisons on DateTime objects:
4343
{% highlight php %}
4444
<?php
4545
if ($start < $end) {
46-
echo "Start is before the end!\n";
47-
}
46+
echo "Start is before the end!" . PHP_EOL;}
4847
{% endhighlight %}
4948
5049
One last example to demonstrate the DatePeriod class. It is used to iterate over recurring events. It can take two

_posts/16-04-01-Mentoring.md

Lines changed: 0 additions & 8 deletions
This file was deleted.

_posts/16-08-01-Sites.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ PHP versions
1515
### More best practices
1616

1717
* [PHP Best Practices](https://phpbestpractices.org/)
18-
* [Best practices for Modern PHP Development](https://www.airpair.com/php/posts/best-practices-for-modern-php-development)
1918
* [Why You Should Be Using Supported PHP Versions](https://kinsta.com/blog/php-versions/)
2019

2120
### News around the PHP and web development communities

pages/Design-Patterns.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,8 @@ print_r($veyron->getMakeAndModel()); // outputs "Bugatti Veyron"
5454
This code uses a factory to create the Automobile object. There are two possible benefits to building your code this
5555
way; the first is that if you need to change, rename, or replace the Automobile class later on you can do so and you
5656
will only have to modify the code in the factory, instead of every place in your project that uses the Automobile class.
57-
The second possible benefit is that if creating the object is a complicated job you can do all of the work in the
58-
factory, instead of repeating it every time you want to create a new instance.
57+
The second possible benefit is that, if creating the object is a complicated job, you can do all of the work in the
58+
factory instead of repeating it every time you want to create a new instance.
5959

6060
Using the factory pattern isn't always necessary (or wise). The example code used here is so simple that a factory
6161
would simply be adding unneeded complexity. However if you are making a fairly large or complex project you may save

0 commit comments

Comments
 (0)