1 | <?php |
||
11 | trait CookieTrait { |
||
12 | |||
13 | /** |
||
14 | * Sets a cookie on the browser, if null value then delete it |
||
15 | * @param string $name |
||
16 | * @param string $value |
||
17 | */ |
||
18 | public function setCookie($name, $value = null) { |
||
29 | |||
30 | /** |
||
31 | * Gets a cookie by its name if exists, else it will return null |
||
32 | * @param string $name |
||
33 | * @return string |
||
34 | */ |
||
35 | public function getCookie($name) { |
||
44 | |||
45 | } |
||
46 |
In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:
Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion: