How to PHP server-side check if a url of a web site is valid?

前端 未结 2 970
轻奢々
轻奢々 2020-12-11 20:26

I\'ve searched our SO questions but found solutions are based on calling ping command executed from using system PHP function.

My web host

2条回答
  •  萌比男神i
    2020-12-11 20:53

    try this:

    //checking if the site exists by fopen, instead of file_get_contents to speed it up
    
    $url = "URL"; //your url goes in this place instead of nabtron.com
    
    if (@fopen($url,"r")) {
    echo "".$url." is accessible
    "; }

提交回复
热议问题