简体   繁体   English

PHP退出后重新启动php脚本?

[英]PHP Restart php script after EXIT?

I have a php script : I put a list of website in a textarea and the php script check if websites are down or UP . 我有一个php脚本:我在textarea中放置了一个网站列表,然后php脚本检查网站是否关闭或启动。 My problem : When a website is down , the script show me an error and stop working with the rest of the list : 我的问题:网站关闭时,脚本会向我显示错误并停止使用列表的其余部分:

Warning: fsockopen() [function.fsockopen]: unable to connect to http://SITEDOWN.com:80 (php_network_getaddresses: getaddrinfo failed: Name or service not known) in /home/checklist/public_html/checklist.php (1) : eval()'d code(1) : eval()'d code(1) : eval()'d code on line 109

when a website is down it show me this error and then the checker stop doing his work and stop all , to fix the error i made this ( i added the DIE to the script) : 当网站关闭时,它会向我显示此错误,然后检查程序停止执行工作并停止所有操作,以修复我所做的错误(我在脚本中添加了DIE):

<?php
    public function sendpacket($host,$packet,$response = 0,$output = 0) 
    {
    $ock = fsockopen($host,80);
    stream_set_timeout($ock,5);
    if (!$ock) 
    {
    echo '=> Site down<br/>'; 
    die;

}

then it dont show me the error but the php script automatically stop when a website is down (It show me SITE DOWN and stop all , no continue with others sites ) I want : When a website is down , it show me "Site Down" and php script restart/CONTINUE with the following line (i use textarea , 1site per line ) 然后它不向我显示错误,但是当网站关闭时php脚本会自动停止(它告诉我网站关闭并停止所有操作,不再继续其他网站)我想要:当网站关闭时,它向我显示“网站关闭”和php脚本restart / CONTINUE并包含以下行(我使用textarea,每行1site)

Sorry for my bad english and thanks to all memmbers who taken the time to read this 对不起,我的英语不好,并感谢所有花时间阅读本手册的会员

Change die to return false and write your calling script to call the function in an if statement... 更改die以返回false并编写调用脚本以在if语句中调用该函数...

    if (sendpacket == false) {
        echo "Fail message";
    } else {
        echo "Success message";
    }

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM