Skip to content

Commit 848849b

Browse files
authored
Update php-interop.md about named constants
1 parent 1b4dc4a commit 848849b

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

content/documentation/php-interop.md

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,22 @@ title = "PHP Interop"
33
weight = 14
44
+++
55

6-
## Accessing super-globals
6+
## Accessing global variables and named constants
77

8-
Use the `php/` prefix to access the global variables in combination with `get`.
8+
Use the `php/` prefix to access the global variables (superglobals) in combination with `get`.
99

1010
```phel
1111
(get php/$_SERVER "key") # Similar to $_SERVER['key']
1212
(get php/$GLOBALS "argv") # Similar to $GLOBALS['argv']
1313
```
1414

15+
Named constants set with PHP [`define`](https://www.php.net/manual/en/function.define.php) can be accessed in Phel via `php/CONSTANT_NAME`.
16+
17+
```
18+
(php/define "MY_SETTING" "My value") # Calls PHP define('MY_SETTING', 'My value");
19+
php/MY_SETTING # Returns "My value"
20+
```
21+
1522
## Calling PHP functions
1623

1724
PHP comes with huge set of functions that can be called from Phel by just adding a `php/` prefix to the function name.

0 commit comments

Comments
 (0)