Thursday, 27 November 2014

parse_ini_string - Parse a configuration string

array parse_ini_string ( string $ini [, bool $process_sections = false [, int $scanner_mode = INI_SCANNER_NORMAL ]] )
Parse a configuration string
parse_ini_string returns the settings in string ini in an associative array.

Function parse_ini_file doesn't parse a remote ini file if allow_url_include is off. But if allow_url_fopen is on, you can use parse_ini_string to parse a remote ini file after read its contents.
/**
* Assume that; allow_url_include=0 and allow_url_fopen=1
* (default values in php.ini)
*/

$iniUrl = 'http://website.com/remote/config.ini';
/**
* Warning: parse_ini_file(): http:// wrapper is disabled in the server configuration by allow_url_include=0
*/
$config = parse_ini_file($iniUrl);

/**
* works fine
*/
$config = parse_ini_string(file_get_contents($iniUrl));

Wednesday, 26 November 2014

stream_socket_client - Open Internet or Unix domain socket connection

resource stream_socket_client ( string $remote_socket [, int &$errno [, string &$errstr [, float $timeout = ini_get("default_socket_timeout") [, int $flags = STREAM_CLIENT_CONNECT [, resource $context ]]]]] )
Open Internet or Unix domain socket connection
Initiates a stream or datagram connection to the destination specified by remote_socket. The type of socket created is determined by the transport specified using standard URL formatting: transport://target. For Internet Domain sockets (AF_INET) such as T

<?php
$fp 
stream_socket_client("tcp://www.example.com:80"$errno$errstr30);
if (!
$fp) {
    echo 
"$errstr ($errno)<br />\n";
} else {
    
fwrite($fp"GET / HTTP/1.0\r\nHost: www.example.com\r\nAccept: */*\r\n\r\n");
    while (!
feof($fp)) {
        echo 
fgets($fp1024);
    }
    
fclose($fp);
}
?>