Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update php-interop.md about named constants #102

Merged
merged 1 commit into from
Dec 8, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions content/documentation/php-interop.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,22 @@ title = "PHP Interop"
weight = 14
+++

## Accessing super-globals
## Accessing global variables and named constants

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

```phel
(get php/$_SERVER "key") # Similar to $_SERVER['key']
(get php/$GLOBALS "argv") # Similar to $GLOBALS['argv']
```

Named constants set with PHP [`define`](https://www.php.net/manual/en/function.define.php) can be accessed in Phel via `php/CONSTANT_NAME`.

```
(php/define "MY_SETTING" "My value") # Calls PHP define('MY_SETTING', 'My value");
php/MY_SETTING # Returns "My value"
```

## Calling PHP functions

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