From 616896d1d863a490e700331cb60d2b30d9cd4fc8 Mon Sep 17 00:00:00 2001 From: Jonathan Date: Thu, 26 Nov 2020 00:44:23 +0100 Subject: [PATCH] Update php.md (#1581) Use type hinting. Use https URLs. Adhere to PHP-FIG PSR-12. --- wip/php.md | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/wip/php.md b/wip/php.md index 3ba62cbf4..c921893cf 100644 --- a/wip/php.md +++ b/wip/php.md @@ -11,8 +11,9 @@ prism_languages: [php] ```php 20, - "banana" => 30 + "apple" => 20, + "banana" => 30 ); echo $fruitsArray['banana']; ``` @@ -53,12 +54,13 @@ var_dump($object) Prints the contents of a variable for inspection. -See: [var_dump](http://php.net/var_dump) +See: [var_dump](https://php.net/var_dump) ### Classes ```php -class Person { +class Person +{ public $name = ''; } @@ -73,14 +75,14 @@ echo $person->name; ```php class Person { - public $name = ''; + private $name = ''; - public function getName() + public function getName(): string { return $this->name; } - public function setName($name) + public function setName(string $name) { $this->name = $name; return $this; @@ -97,13 +99,12 @@ echo $person->getName(); ```php $options = [ - 'key' => 'value', - 'blank' => '', - 'nothing' => null, + 'key' => 'value', + 'blank' => '', + 'nothing' => null, ]; var_dump(isset($options['key']), empty($options['key'])); // true, false var_dump(isset($options['blank']), empty($options['blank'])); // true, true var_dump(isset($options['nothing']), empty($options['nothing'])); // false, true - ```