From 81c7c624144512e3cf2ccfe85efa2827ee0831d2 Mon Sep 17 00:00:00 2001 From: Pen-y-Fan <40126936+Pen-y-Fan@users.noreply.github.com> Date: Sun, 2 May 2021 12:15:44 +0100 Subject: [PATCH] End of Line (#888) End of line changed from `\n` to `PHP_EOL` --- _posts/03-05-01-Command-Line-Interface.md | 4 ++-- _posts/05-03-01-Date-and-Time.md | 7 +++---- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/_posts/03-05-01-Command-Line-Interface.md b/_posts/03-05-01-Command-Line-Interface.md index a9c7de5..846ab34 100644 --- a/_posts/03-05-01-Command-Line-Interface.md +++ b/_posts/03-05-01-Command-Line-Interface.md @@ -27,11 +27,11 @@ Let's write a simple "Hello, $name" CLI program. To try it out, create a file na {% highlight php %} .\n"; + echo "Usage: php hello.php " . PHP_EOL; exit(1); } $name = $argv[1]; -echo "Hello, $name\n"; +echo "Hello, $name" . PHP_EOL; {% endhighlight %} PHP sets up two special variables based on the arguments your script is run with. [`$argc`][argc] is an integer diff --git a/_posts/05-03-01-Date-and-Time.md b/_posts/05-03-01-Date-and-Time.md index a6a1cef..2837c8e 100644 --- a/_posts/05-03-01-Date-and-Time.md +++ b/_posts/05-03-01-Date-and-Time.md @@ -19,7 +19,7 @@ output. $raw = '22. 11. 1968'; $start = DateTime::createFromFormat('d. m. Y', $raw); -echo 'Start date: ' . $start->format('Y-m-d') . "\n"; +echo 'Start date: ' . $start->format('Y-m-d') . PHP_EOL; {% endhighlight %} Calculating with DateTime is possible with the DateInterval class. DateTime has methods like `add()` and `sub()` that @@ -34,7 +34,7 @@ $end = clone $start; $end->add(new DateInterval('P1M6D')); $diff = $end->diff($start); -echo 'Difference: ' . $diff->format('%m month, %d days (total: %a days)') . "\n"; +echo 'Difference: ' . $diff->format('%m month, %d days (total: %a days)') . PHP_EOL; // Difference: 1 month, 6 days (total: 37 days) {% endhighlight %} @@ -43,8 +43,7 @@ You can use standard comparisons on DateTime objects: {% highlight php %}