您好我有以下功能抓住和保存屏幕截图。 它的工作原理的50%的时间,但它有时会失败,以下消息: 警告:file_put_contents()预计至少2个参数,1给出警告:file_put_contents()期望至少2个参数 - 但我给2参数
我已倒出的2个参数,并可以看到,它们都存在,但错误信息提示,否则
其驾驶我疯了,任何帮助,将不胜感激..
<?php
grab_screenshot('http://www.usa4ink.com', 480, 240,"myscreen.jpg")
function grab_screenshot($url, $w, $h,$filename)
{
global $imgPath;
$filename = make_filename($filename,"jpg");
$url = urlencode($url);
$url = "http://s.wordpress.com/mshots/v1/$url/?w=$w&h=$h";
$url = str_replace("//","/",$url);
$url = str_replace("http:/","http://",$url);
$image = file_get_contents($url);
if($image!='')
{
file_put_contents(str_replace("//","/",$imgPath."/".get_subDir($filename)."/".$filename, $image));
}
return get_subDir($filename)."/".$filename;
}
?>
你错过了第二个参数,你为'str_replace'传递了两个参数,而不是'file_put_contents' –
@PragneshChauhan:传递了'4'参数到'str_replace'和'1'参数到'file_put_contents' –