# Determining if a PHP function is available

> Check whether a PHP function is enabled on your hosting account using function_exists(), with a working example.

Source: https://helpcenter.ruachost.com/developers/php/determining-if-a-php-function-is-available/

Sometimes you need to check whether a specific PHP function is enabled on your hosting account. On **ruachost.com**, you can do this using the built‑in `function_exists()` function.

## Why Check Function Availability?

- Hosting environments may disable certain PHP functions for security reasons.
- Ensures your script won’t break if a function is unavailable.
- Helps you write portable code that works across different servers.

## Using the `function_exists()` Function

The `function_exists()` function returns **true** if the specified function is available, and **false** if it is not.

### Example: Checking for `fsockopen()`

```
<?php
$function_name = "fsockopen";

if (function_exists($function_name)) {
    echo "$function_name is enabled";
} else {
    echo "$function_name is not enabled";
}
?>
```

### Steps:

1. Save the file as `function.php`.
2. Upload it to your `public_html` directory.
3. Visit `http://yourdomain.com/function.php`.
4. The page will display whether the function is enabled.

> **More Information:**
- You can replace `"fsockopen"` with any other function name you want to check.
- Useful for functions like `curl_init`, `mail`, or `exec`.
- For official documentation, see the PHP manual on function_exists.
