Merge pull request #18 from Girgias/patch-1

Use `const` for constants instead of define()
This commit is contained in:
Randy8080 authored and GitHub committed 2021-01-06 12:45:50 +08:00
commit a032ab1a99
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 {