• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
The Electric Toolbox Blog

The Electric Toolbox Blog

Linux, Apache, Nginx, MySQL, Javascript and PHP articles

  • Applications
  • FCKEditor
  • Apache
  • Windows
  • Contact Us
Home / PHP Quick Tip: Check if URL aware fopen wrappers are enabled

PHP Quick Tip: Check if URL aware fopen wrappers are enabled

PHP supports opening remote URLs (e.g. http://www.example.com/something.htmnl) using the fopen and similar functions. It is possible to disable this function in the PHP configuration so this quick tip shows how to check if it is possible to open remote URLs.

The configuration option

The configuration option that enables or disables opening remote URLs is “allow_url_fopen” and will appear in the configuration file like this:

allow_url_fopen = On

Note that this setting can only be set in the main php.ini configuration file so if your hosting provider has disabled it then you will be able to open remote URLs with fopen etc.

Test if it is enabled

To test if opening remote URLs is enabled do this:

if( ini_get('allow_url_fopen') ) {
    // it's enabled, so do something
}
else {
    // it's not enabled, so do something else
}

If opening remote URLs is not enabled, then you will need to enable this option in the main php.ini configuration or see if your hosting provider will do this for you. Otherwise you will need to use CURL to download files, assuming that CURL is available.

Check Out These Related posts:

  1. PHP’s file_get_contents and CURL functions
  2. Scp command
  3. What Is a VPN?
  4. Download a sequence of files with curl

Filed Under: PHP, Quick Tips

Primary Sidebar

Categories

  • Apache
  • Applications
  • Article
  • Case Studies
  • Email Servers
  • FCKEditor
  • HTML And CSS
  • Javascript
  • Linux/Unix/BSD
  • Microsoft SQL Server
  • Miscellaneous Postings
  • MySql
  • Networking
  • Nginx Web Server
  • Offsite Articles
  • OSX
  • PHP
  • Quick Tips
  • RFC – Request for Comments
  • SilverStripe
  • VMWare
  • VPN
  • Windows
  • WordPress

Recent Posts

  • Vim Show Line Numbers
  • Add User To Group Linux
  • Chmod 777 Tutorial
  • How to Copy Directory Linux
  • Linux create user

Copyright © 2021. ElectricToolBox. All Rights Reserved.

  • Contact Us
  • Copyright Info
  • Privacy Policy
  • Sitemap