# esc()

Escape context specific output

****

- Source: <https://github.com/getkirby/kirby/tree/5.5.3/config/helpers.php#L166>

****

```php
esc(string $string, string $context = 'html'): string
```

## Parameters

| Name | Type | Default | Description |
| ---- | ---- | ---- | ---- |
| `$string` (required) | `string` | – | Untrusted data |
| `$context` | `string` | `'html'` | Location of output (`html`, `attr`, `js`, `css`, `url` or `xml`) |

## Return type

`string`

Escaped data

## Examples

```php
<p><?= esc('untrusted data') ?></p>
```

```php
<img alt="<?= esc($alt, 'attr') ?>" src="/your-image.jpg" />
```

```php
<section style="--columns: <?= esc($columns, 'css')">
...
</section>
```

```php
<script>
let yourVariable = "<?= esc($variable, 'js') ?>";

// ...
</script>
```

```php
<iframe src="https://map.example.com/?lat=<?= esc($lat, 'url') ?>&lon=<?= esc($lon, 'url') ?>"></iframe>
```