小编Jun*_*uni的帖子

用php生成图片,背景总是颜色不对

功能是当用户上传一张图片时,程序会生成一个新的白色背景的方形图片,并将用户的图片放在这张图片的中心。

但问题是,我将背景设置为白色,它总是显示黑色。

代码是

$capture = imagecreatetruecolor($width, $height);
$rgb = explode(",", $this->background); 
$white = imagecolorallocate($capture, $rgb[0], $rgb[1], $rgb[2]); 
imagefill($capture, 0, 0, $white); 
Run Code Online (Sandbox Code Playgroud)

和控制颜色的代码是 protected $background = "255,255,255";

我一直在尝试更改$white = imagecolorallocate($capture, $rgb[0], $rgb[1], $rgb[2]);$white = imagecolorallocate($capture, 255, 255, 255);. 但是背景仍然显示为黑色。

感谢您的任何回答

php gd image

7
推荐指数
1
解决办法
3688
查看次数

警告:strlen()期望参数1是字符串,给定数组

可能重复:
mysql_fetch_array()期望参数1是资源,在select中给出boolean

我将我的网站转移到新主机上.以前的php版本是5.2,现在是5.3.我更改了php版本后,几乎每个页面都显示警告:

strlen() expects parameter 1 to be string, array given
Run Code Online (Sandbox Code Playgroud)

错误行是此函数中的第三行:

function implodestr($arr,$field) {
    unset($out_str);
    if (!is_array($arr) || !$arr || strlen($arr)==0)  return 0; //error line
    foreach($arr as $k=>$v) {
        $out_str.= $v[$field].","; 
    }
    $str = trim($out_str,",");
    $str ? "": $str=0;
    return $str;
}
Run Code Online (Sandbox Code Playgroud)

php warnings strlen

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

语法错误,意外的T_GOTO,期待T_STRING

我将我的网站移动到另一个主机.以前的php版本是5.2,现在是5.3当我登录我的网站时,它显示错误:

Parse error: syntax error, unexpected T_GOTO, expecting T_STRING in /xx/xx/xx/xx on line xx
Run Code Online (Sandbox Code Playgroud)

以下是代码,第一行是错误行:

    function goto($URL= "Back",$Target="self") //the error line
{
    if ($URL == "Back")
    {
        echo "<HTML>\n<HEAD>\n<TITLE> untitle </TITLE>\n<meta http-equiv=\"Content-Type\"  content=\"text/html; charset={$this -> Charset}\">\n</HEAD>\n<BODY>\n";
        echo "<Script Language=\"Javascript\">history.go(-1)</Script>";
        echo "\n</body></html>";
    }
    elseif
Run Code Online (Sandbox Code Playgroud)

我该如何更改语法?非常感谢!

php syntax-error

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

标签 统计

php ×3

gd ×1

image ×1

strlen ×1

syntax-error ×1

warnings ×1