Skip to content

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.

  • 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.

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

<?php
$function_name = "fsockopen";
if (function_exists($function_name)) {
echo "$function_name is enabled";
} else {
echo "$function_name is not enabled";
}
?>
  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.