小编Xpe*_*lay的帖子

PHP - 设置file_get_contents超时

file_get_contents用来获取外部页面的标题,以确定外部页面是否在线,如下所示:

$URL = "http://page.location/";
$Context = stream_context_create(array(
'http' => array(
    'method' => 'GET',
)
));
file_get_contents($URL, false, $Context);
$ResponseHeaders = $http_response_header;

$header = substr($ResponseHeaders[0], 9, 3);

if($header[0] == "5" || $header[0] == "4"){
//do stuff
}
Run Code Online (Sandbox Code Playgroud)

除非页面花费太长时间才能响应,否则这种方法很有效.

如何设置超时?

file_get_headers返回FALSE,如果还没有完成,将PHP移到下一行,如果还没有完成的file_get_contents请求?

php arrays function file-get-contents http-headers

11
推荐指数
2
解决办法
2万
查看次数

jQuery从元素中删除mCsutomScrollbar

在jQuery UI对话框上使用mCustomScrollbar.

如果我按照mCsutomScrollbar指令中的建议在$(window).load上启动mCsutomScrollbar,它就不起作用,因为那时我的对话框不可见.所以我必须在对话框的open事件上启动mCsutomScrollbar.

open: function() {
    $(this).mCustomScrollbar();
    }
Run Code Online (Sandbox Code Playgroud)

除非我第二次打开同一个对话框,否则mCustomScrollbar第二次初始化时已经初始化并中断了.我可以看到自定义滚动条但我无法滚动.

所以我似乎需要一种方法来删除对话框的close或beforeclose事件中的mCustomScrollbar.不完全确定如何做到这一点.

javascript jquery jquery-ui jquery-ui-dialog

2
推荐指数
1
解决办法
5317
查看次数