Set TimeOut in file_get_contents

            $ctx_opts = array('http' => array('timeout' => 10));
            $context = stream_context_create($ctx_opts);
            $response = file_get_contents($URL, false, $context);

            if ($response === false) {
                $error_message = error_get_last();
                echo  $error_message;
            }

WampServer Multiple PHP Versions

This  document is intended for use with:
WampServer version 2.5 : Apache : 2.4.9 MySQL : 5.6.17 PHP : 5.5.12
Sometimes, you need to run multiple PHP versions for some projects using wamp.  So this time I will show you how to configure wamp server 2.5  to run several php versions(one per time). Lets start:
1. Download phpxxxxxx.zip package for windows from  http://windows.php.net/downloads/releases/archives/.   i.e. php-7.0.0
2. Extract it on yourpath/wamp/bin/php/php5.x.xx folder (i.e wamp/bin/php/php7.0.0/)

Lets Start the configuration. Lets go in wamp/bin/php/php7.0.0/  (working directory for steps 3 to 5)

3. Copy and paste php.ini-development and rename it to php.ini and open it for editing.
a. Search the word “extension_dir” and add the follow line
extension_dir = “C:/path/to/your/wamp/bin/php/php7.0.0/ext/”
b. Then search “upload_tmp_dir and add
upload_tmp_dir = “C:/path/to/your/wamp/tmp
c. Search “http://php.net/session.save-path” and add the follow line below it
session.save_path = “C:/path/to/your/wamp/tmp
4.  Now copy the php.ini and paste it as “phpForApache.ini” in the same folder. So you will have php.ini and phpForApache.ini.
5. Create a new file called wampserver.conf and paste the following content.
<?php
 $phpConf['phpIniDir'] = '.';
 $phpConf['phpExeDir'] = '.';
 $phpConf['phpConfFile'] = 'php.ini';

 $phpConf['apache']['2.4']['LoadModuleName'] = 'php5_module';
 $phpConf['apache']['2.4']['LoadModuleFile'] = 'php5apache2_4.dll';
 $phpConf['apache']['2.4']['AddModule'] = '';

 $phpConf['apache']['2.4']['LoadModuleName'] = 'php7_module';
 $phpConf['apache']['2.4']['LoadModuleFile'] = 'php7apache2_4.dll';
 $phpConf['apache']['2.4']['AddModule'] = '';
?>
6. Now open C:/path/to/wamp/wampmanager.ini to tell wamp that we have another php version. Search the section [phpVersion] and add the line as follow :
Type: item; Caption: "7.0.0"; Action: multi; Actions:switchPhp7.0.0
Then search this line:
Parameters: "http://www.wampserver.com/addons_php.php";
And add the following lines below it:

[switchPhp7.0.0]
Action: resetservices
Action: readconfig;

Thats all. Close wampserver and open it again. you will see the new php version to be elegible.
Remember to change  C:/path/to/wamp to your wamp path.
PD: Please comment any mistake or issue.  I will try to improve this article later.  Hope, it can help someone.

List Directory in php

<?php

$dir    = '/tmp';
$files1 = scandir($dir);
$files2 = scandir($dir, 1);

print_r($files1);
print_r($files2);

?>