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

# Enabling and disabling the PHP allow_url_fopen directive

> Learn to enable or disable allow_URL_fopen in php.ini with our guide, complete with instructions and code snippets.

This article describes how to enable and disable the **allow\_url\_fopen** directive in a custom *php.ini* file.

<Warning>
  **Important**

  The information in this article only applies to certain types of hosting accounts. To determine whether or not the information below applies to your account, please see [this article](/docs/changing-php-settings-and-versions).

  📘 Note

  This article assumes that you have already set up a custom *php.ini* file on your web site. If you have not already set up a custom *php.ini* file, please read [this article](/docs/custom-php-ini-files) first.
</Warning>

## Using the allow\_url\_fopen directive

<Warning>
  **️ Warning**

  The **allow\_url\_fopen** directive is disabled by default. You should be aware of the security implications of enabling the **allow\_url\_fopen** directive. PHP scripts that can access remote files are potentially vulnerable to arbitrary code injection.
</Warning>

When the **allow\_url\_fopen** directive is enabled, you can write scripts that open remote files as if they are local files. For example, you can use the **file\_get\_contents** function to retrieve the contents of a web page.

To enable this functionality, use a text editor to modify the **allow\_url\_fopen** directive in the *php.ini* file as follows:

```
allow_url_fopen = on
```

To disable this functionality, modify the **allow\_url\_fopen** directive in the *php.ini* file as follows:

```
allow_url_fopen = off
```

<Tip>
  To verify the current value of the **allow\_url\_fopen** directive and other directives, you can use the **phpinfo()** function. For more information, please see [this article](/docs/view-php-settings).
</Tip>

## More information

* To view a complete list of *php.ini* directives, please visit [http://www.php.net/manual/en/ini.list.php](http://www.php.net/manual/en/ini.list.php).

* For more information about the **allow\_url\_fopen** directive, please visit [http://www.php.net/manual/en/filesystem.configuration.php#ini.allow-url-fopen](http://www.php.net/manual/en/filesystem.configuration.php#ini.allow-url-fopen).

* For more information about the **file\_get\_contents** function, please visit [http://www.php.net/file\_get\_contents](http://www.php.net/file_get_contents).

## Related articles

* [Custom php.ini files](/docs/custom-php-ini-files)

* [Using php.ini directives](/docs/using-php-ini-directives)
