---
title: if
summary: null
url: https://www.fastly.com/documentation/reference/vcl/functions/miscellaneous/if
---

```
STRING if(BOOL condition, STRING value_when_true, STRING value_when_false)
```

**Available in:** all subroutines

Tests a given `condition`, and returns `value_when_true` when the condition is TRUE, and
returns `value_when_false` when the condition is FALSE.

You can use `if()` as a construct to make simple, conditional expressions 
more concise.

## Example

```vcl
set req.http.foo-status = if(req.http.foo, "present", "absent");
```
