Use const for constants instead of define()

Move ``define()`` to a new section about Runtime defined constants.
This commit is contained in:
George Peter Banyard authored and GitHub committed 2021-01-05 22:45:25 +00:00
1 parent 4e8b42d827
commit ed4091f0c2
1 file changed
+15 -1
+15 -1
View File
@@ -148,7 +148,7 @@ See: [Functions](#functions-3)
### Constants
```php
define("MY_CONST", "hello");
const MY_CONST = "hello";
echo MY_CONST; # => hello
@@ -157,6 +157,20 @@ echo 'MY_CONST is: ' . MY_CONST;
```
### Runtime defined Constants
```php
define("CURRENT_DATE", date('Y-m-d'));
// One possible representation
echo CURRENT_DATE; # => 2021-01-05
# => CURRENT_DATE is: 2021-01-05
echo 'CURRENT_DATE is: ' . CURRENT_DATE;
```
### Classes
```php
class Student {