Test procedure:
Exec ("ping baidu.com", $ list );
For ($ I = 0; $ I <count ($ list); $ I ++ ){
Print $ list [$ I]. "\ n ";
}
?>
Chinese materials:
This function is generally only used in linux
Few people put php on a windows server to run it. Some functions in php only support linux. Not all functions can be used on windows!
Exec can be used on win
To run exec in IIS + PHP, you first need to grant the permission to php‑read.exe(users need to add internet Guest user permissions to the security of cmd.exe). Otherwise, an error will occur.
Apache does not know what permissions are used for running, and does not know whether it is a permission issue.
E document:
It's because your host has limited certain functions of PHP.
Exec is a PHP-specific function that your web host disabled with PHP safe mode
It seems that many permissions in windows are not so well solved. Is there any other way to run in xp?
After asking many friends, I finally found the following two functions. Fsockopen and fopen, but both functions have limitations.
If the link is lost, the page will remain stuck and there is no timeout parameter, which is difficult to control.
Fsockopen requires a domain name, but a lot of data in my database is ip addresses, such as http: // 202,234.34 .54, which leads to misjudgment. (I finally used this method)
I found a function on the Internet to extract domain names, but I couldn't find the function, including the www function. Alas, I don't want to be lazy. But I wrote a function get_domain ($ url ){
$ Url1 = $ url;
$ Upos = strpos ($ url1, "http ://");
If ($ upos = 0) $ url1 = str_replace ("http: //", "", $ url1 );
$ Upos = strpos ($ url1 ,"/");
If ($ upos ){
$ Url2 = substr ($ url1, 0, $ upos );
}
Return $ url2;
} // End function
The following is the test code:
Function test ($ testurl ){
$ Fp = @ fsockopen ($ testurl, 80, & $ errno, & $ errstr, 2 );
If (gettype ($ fp )! = Resource ){
$ Remark = "the URL link is invalid! ";
}
}
This function is described in detail on the Internet Many, need to be searched by friends themselves.