Check internet connection with php

Responsive image

Hi, we do internet connection control with this article in PHP example.

How do i know if connect to the internet?

if 80th port returns true, know internet connection is successfully.

look at the example;

function is_connected()
    $connected = @fsockopen("", 80); 
                                        //website, port  (try 80 or 443)
    if ($connected){
        $is_conn = true; //action when connected
        $is_conn = false; //action in connection failure
    return $is_conn;


What does it do?

  • Check internet or website connection
  • internet based scripts for internet connection