How to check ports are open or not in php?

I want to check which ports are enable or disable ports in php.

Starter Asked on January 7, 2018 in PHP.
Add Comment
1 Answer(s)

Finally i got solution for this question.

<?php
            $fp = fsockopen('127.0.0.1', 25, $errno, $errstr, 5);
            if (!$fp) {
                        echo "port is closed or blocked";
            } else { 
                       echo "port is open and available";
                       fclose($fp);
           }
?>

 

 

Starter Answered on January 7, 2018.
Add Comment

Your Answer

By posting your answer, you agree to the privacy policy and terms of service.