Update php.md (#1581)
Use type hinting. Use https URLs. Adhere to PHP-FIG PSR-12.
This commit is contained in:
parent
fbd66d4838
commit
616896d1d8
17
wip/php.md
17
wip/php.md
|
@ -11,7 +11,8 @@ prism_languages: [php]
|
|||
|
||||
```php
|
||||
<?php
|
||||
function greetMe($name) {
|
||||
function greetMe($name): string
|
||||
{
|
||||
return "Hello, " . $name . "!";
|
||||
}
|
||||
|
||||
|
@ -21,7 +22,7 @@ echo $message;
|
|||
|
||||
All PHP files start with `<?php`.
|
||||
|
||||
See: [PHP tags](http://php.net/manual/en/language.basic-syntax.phptags.php)
|
||||
See: [PHP tags](https://php.net/manual/en/language.basic-syntax.phptags.php)
|
||||
|
||||
### Objects
|
||||
|
||||
|
@ -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;
|
||||
|
@ -105,5 +107,4 @@ $options = [
|
|||
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
|
||||
|
||||
```
|
||||
|
|
Loading…
Reference in New Issue