> ## Documentation Index
> Fetch the complete documentation index at: https://docs.riza.io/llms.txt
> Use this file to discover all available pages before exploring further.

# PHP

> Execute PHP scripts in a secure and isolated runtime environment

<Note>
  This page is about the PHP interpreter
  environment inside the Riza Code Interpreter API.
  We have not yet published an API client library for PHP.
</Note>

## Runtime

Riza runs the CGI version of [PHP 8.2.6](https://www.php.net/ChangeLog-8.php#8.2.6)
compiled to WASM. The entire standard library is included.

Because PHP is running in CGI mode (rather than CLI mode) there are a few quirks.
For instance there are miscellaneous environment variables set that aren't
meaningful in the context of a standalone script.

We've done some work to round off the rough edges, though there are limitations.

## Limitations

When PHP is running as a CGI program it doesn't provide access to the constants
`STDIN`, `STDOUT` and `STDERR` and corresponding
`php://stdin`, `php://stdout` and `php://stderr` [I/O
streams](https://www.php.net/manual/en/wrappers.php.php). The `php://input`
and `php://output` streams work as expected.

The PHP interpreter also doesn't populate command line parameters in `$argv`
when running as a CGI program.

See our [roadmap](/reference/roadmap) for planned future improvements.

## Output

You can write to `stdout` with `echo` or using the `php://output` stream.
Write to `stderr` with
[`error_log`](https://www.php.net/manual/en/function.error-log.php).

```php theme={null}
<?php 
echo "Hello, ";
file_put_contents("php://output", "world!");
error_log("Something went wrong");
?>
```

## Input

You can read from `stdin` using the `php://input` stream, and access environment
variables using `$_ENV`. Unfortunately `$argv` isn't populated.

```php theme={null}
$input = file_get_contents("php://input");
$foo = $_ENV["FOO"];
```
