我用php创建透明文本 - > png图像,到目前为止一直很好.唯一的问题是我希望能够通过固定的宽度来进行文本自动换行.或者也可以在文本中插入断行符.有没有人有任何exp这样做?这是我的代码......
<?php
$font = 'arial.ttf';
$text = 'Cool Stuff! this is nice LALALALALA LALA HEEH EHEHE';
$fontSize = 20;
$bounds = imagettfbbox($fontSize, 0, $font, $text);
$width = abs($bounds[4]-$bounds[6]);
$height = abs($bounds[7]-$bounds[1]);
$im = imagecreatetruecolor($width, $height);
imagealphablending($im, false);
imagesavealpha($im, true);
$trans = imagecolorallocatealpha($im, 255, 255, 255, 127);
// Create some colors
$white = imagecolorallocate($im, 255, 255, 255);
$grey = imagecolorallocate($im, 128, 128, 128);
$black = imagecolorallocate($im, 0, 0, 0);
imagecolortransparent($im, $black);
imagefilledrectangle($im, 0, 0, $width, $height, $trans);
// …Run Code Online (Sandbox Code Playgroud) 我让用户输入一些将存储在sql中的信息.当然我想要逃避所有的引号等...但我不希望那些东西输出到最终的html中.
我正在为所有$ _POST变量运行此函数.有效吗?
function cleanArray($array) //prevent funky insertions
{
foreach ($array as &$value)
{
$value = mysql_real_escape_string(stripslashes(nl2br($value)));
}
return $array;
}
Run Code Online (Sandbox Code Playgroud)
我担心逃脱字符串和striplashes互相取消?