Php 警告:file_put_contents()至少需要2个参数,但我提供了2个参数

Php 警告:file_put_contents()至少需要2个参数,但我提供了2个参数,php,Php,嗨,我有下面的功能,抓取和保存屏幕截图。 它在50%的时间内工作,但有时会出现以下消息: 警告:file\u put\u contents()至少需要两个参数,给定一个 我已经甩出了这两个参数,可以看到它们都存在,但错误消息表明并非如此 这让我抓狂,任何帮助都将不胜感激 <?php grab_screenshot('http://www.usa4ink.com', 480, 240,"myscreen.jpg") function grab_screenshot($url, $w, $

嗨,我有下面的功能,抓取和保存屏幕截图。 它在50%的时间内工作,但有时会出现以下消息: 警告:file\u put\u contents()至少需要两个参数,给定一个

我已经甩出了这两个参数,可以看到它们都存在,但错误消息表明并非如此

这让我抓狂,任何帮助都将不胜感激

<?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;
}
?>

不,你没有。仔细看看

file_put_contents(str_replace(param, param, param, param))
不,你没有。仔细看看

file_put_contents(str_replace(param, param, param, param))

这是您返回前的代码:

file_put_contents(
    str_replace("//","/",$imgPath."/".get_subDir($filename)."/".$filename, $image)
);

如您所见,您给出了1个参数,这是您在返回之前的代码:

file_put_contents(
    str_replace("//","/",$imgPath."/".get_subDir($filename)."/".$filename, $image)
);

如您所见,您给出了1个参数检查括号:

file_put_contents(str_replace("//","/",$imgPath."/".get_subDir($filename)."/".$filename, $image));
应该是:

file_put_contents(str_replace("//","/",$imgPath."/".get_subDir($filename)."/".$filename),  $image);

检查括号:

file_put_contents(str_replace("//","/",$imgPath."/".get_subDir($filename)."/".$filename, $image));
应该是:

file_put_contents(str_replace("//","/",$imgPath."/".get_subDir($filename)."/".$filename),  $image);

您缺少第二个参数,您为
str\u replace
传递了两个参数,而不是为
file\u put\u contents
@PragneshChauhan:将
4
参数传递到
str\u replace
1
参数传递到
file\u put\u contents
您缺少第二个参数,您已将两个参数传递给
str\u replace
file\u put\u contents
@PragneshChauhan:将
4
参数传递给
str\u replace
1
参数传递给
file\u put\u contents