Return to Snippet

Revision: 61942
at August 2, 2013 03:01 by phpdev


Updated Code
<?php
/**
 * Check Internet Connection.
 * 
 * @author           Pierre-Henry Soria <[email protected]>
 * @copyright        (c) 2012-2013, Pierre-Henry Soria. All Rights Reserved.
 * @param            string $sCheckHost Default: www.google.com
 * @return           boolean
 */
function check_internet_connection($sCheckHost = 'www.google.com') 
{
    return (bool) @fsockopen($sCheckHost, 80, $iErrno, $sErrStr, 5);
}
?>

Revision: 61941
at January 24, 2013 23:41 by phpdev


Updated Code
<?php
/**
 * Check Internet Connection.
 * 
 * @author           Pierre-Henry Soria <[email protected]>
 * @copyright        (c) 2012-2013, Pierre-Henry Soria. All Rights Reserved.
 * @param string $sCheckHost Default: www.google.com
 * @return boolean
 */
function check_internet_connection($sCheckHost = 'www.google.com') 
{
    return (bool) @fsockopen($sCheckHost, 80, $iErrno, $sErrStr, 5);
}
?>

Revision: 61940
at January 24, 2013 23:40 by phpdev


Updated Code
<?php
/**
 * Check Internet Connection.
 * 
 * @author           Pierre-Henry Soria <[email protected]>
 * @copyright        (c) 2013, Pierre-Henry Soria. All Rights Reserved.
 * @param string $sCheckHost Default: www.google.com
 * @return boolean
 */
function check_internet_connection($sCheckHost = 'www.google.com') 
{
    return (bool) @fsockopen($sCheckHost, 80, $iErrno, $sErrStr, 5);
}
?>

Revision: 61939
at January 24, 2013 23:40 by phpdev


Initial Code
<?php
/**
 * Check Internet Connection.
 * 
 * @author           Pierre-Henry Soria <[email protected]>
 * @copyright        (c) 2012-2013, Pierre-Henry Soria. All Rights Reserved.
 * @param string $sCheckHost Default: www.google.com
 * @return boolean
 */
function check_internet_connection($sCheckHost = 'www.google.com') 
{
    return (bool) @fsockopen($sCheckHost, 80, $iErrno, $sErrStr, 5);
}
?>

Initial URL


Initial Description
**Example of use:**

    $bIsConnected = check_internet_connection();
    $sText = ($bIsConnected) ? 'You are connected to the Internet.' : 'You are not connected to the Internet.';
    echo $sText;

Initial Title
Check your Internet connection with PHP

Initial Tags
php, web

Initial Language
PHP