求php大神看一下,怎么才能把GET传来的值,替换成我想输出的文字,比如$text接收GET传来的参数? 100
<?phpclassshowChinaText{var$text='we';var$font='fonts/simsun.ttc';//如果没有要自己加载到相应的目录下(...
<?php
class showChinaText{
var $text = 'we';
var $font = 'fonts/simsun.ttc'; //如果没有要自己加载到相应的目录下(本地www)
var $angle = 0;
var $size = 15;
var $showX = 165;
var $showY = 130;
var $text0 = '姓名';
var $angle0 = 0;
var $showX0 = 260;
var $showY0 = 330;
var $text1 = '13082719940808965';
var $angle1 = 0;
var $showX1 = 488;
var $showY1 = 330;
function showChinaText($showText = '') {
$this->text = ! isset ( $showText ) ? $showText : $this->text;
$this->show ();
}
function createText($instring) {
$outstring = "";
$max = strlen ( $instring );
for($i = 0; $i < $max; $i ++) {
$h = ord ( $instring [$i] );
if ($h >= 160 && $i < $max - 1) {
$outstring .= substr ( $instring, $i, 2 );
$i ++;
} else {
$outstring .= $instring [$i];
}
}
return $outstring;
}
function show() {
Header ( "Content-type: image/png" );
$image = imagecreatefromjpeg ( "01.jpg" ); //这里的图片,换成你的图片路径
$red = ImageColorAllocate ( $image, 255, 212, 88 );
$white = ImageColorAllocate ( $image, 255, 212, 88);
$black = ImageColorAllocate ( $image, 0, 0, 0 );
$txt = $this->createText ( $this->text );
$txt0 = $this->createText ( $this->text0 );
$txt1 = $this->createText ( $this->text1 );
imagettftext ( $image, $this->size, $this->angle, $this->showX, $this->showY, $white, $this->font, $txt );
imagettftext ( $image, $this->size, $this->angle0, $this->showX0, $this->showY0, $white, $this->font, $txt0 );
imagettftext ( $image, $this->size, $this->angle1, $this->showX1, $this->showY1, $white, $this->font, $txt1 );
imagejpeg ( $image );
imagegif ( $image, "a2.jpg" );
ImageDestroy ( $image );
}
}
?>
<?php
$s = new showChinaText();
?> 展开
class showChinaText{
var $text = 'we';
var $font = 'fonts/simsun.ttc'; //如果没有要自己加载到相应的目录下(本地www)
var $angle = 0;
var $size = 15;
var $showX = 165;
var $showY = 130;
var $text0 = '姓名';
var $angle0 = 0;
var $showX0 = 260;
var $showY0 = 330;
var $text1 = '13082719940808965';
var $angle1 = 0;
var $showX1 = 488;
var $showY1 = 330;
function showChinaText($showText = '') {
$this->text = ! isset ( $showText ) ? $showText : $this->text;
$this->show ();
}
function createText($instring) {
$outstring = "";
$max = strlen ( $instring );
for($i = 0; $i < $max; $i ++) {
$h = ord ( $instring [$i] );
if ($h >= 160 && $i < $max - 1) {
$outstring .= substr ( $instring, $i, 2 );
$i ++;
} else {
$outstring .= $instring [$i];
}
}
return $outstring;
}
function show() {
Header ( "Content-type: image/png" );
$image = imagecreatefromjpeg ( "01.jpg" ); //这里的图片,换成你的图片路径
$red = ImageColorAllocate ( $image, 255, 212, 88 );
$white = ImageColorAllocate ( $image, 255, 212, 88);
$black = ImageColorAllocate ( $image, 0, 0, 0 );
$txt = $this->createText ( $this->text );
$txt0 = $this->createText ( $this->text0 );
$txt1 = $this->createText ( $this->text1 );
imagettftext ( $image, $this->size, $this->angle, $this->showX, $this->showY, $white, $this->font, $txt );
imagettftext ( $image, $this->size, $this->angle0, $this->showX0, $this->showY0, $white, $this->font, $txt0 );
imagettftext ( $image, $this->size, $this->angle1, $this->showX1, $this->showY1, $white, $this->font, $txt1 );
imagejpeg ( $image );
imagegif ( $image, "a2.jpg" );
ImageDestroy ( $image );
}
}
?>
<?php
$s = new showChinaText();
?> 展开
1个回答
展开全部
例如你的语句:
var $text = 'we';
这是一个固定赋值的语句,如果你需要使用GET参数we的值,那么可以这样写:
var $text = $_GET['we'];
其结果是调用此PHP时候传递来的参数值,例如abc.php?we=def,那么变量$text的值为'def‘’
var $text = 'we';
这是一个固定赋值的语句,如果你需要使用GET参数we的值,那么可以这样写:
var $text = $_GET['we'];
其结果是调用此PHP时候传递来的参数值,例如abc.php?we=def,那么变量$text的值为'def‘’
更多追问追答
追问
我这样试过,但是这样的话就显示不出来图片了。
追答
imagettftext里面的字符串要使用UTF8格式,你先试试看英文能否显示,如果英文可以,那多半就是编码的问题,转换编码可以使用iconv函数。
string iconv ( string $in_charset , string $out_charset , string $str )
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询