功能是当用户上传一张图片时,程序会生成一个新的白色背景的方形图片,并将用户的图片放在这张图片的中心。
但问题是,我将背景设置为白色,它总是显示黑色。
代码是
$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版本是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版本是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)
我该如何更改语法?非常感谢!