1
I’m using the GD Library, I have the code below and I want to put a line break $texto = "primeira linha\nsegunda linha";
, but it needs to go through $get
.
What I mean by go through $get
is that if you replace the line
$texto = $_GET['texto'];
for
$texto = "linha1\n linha2";
in the archive img.php
the \n
will break the line and using the form in method get
the text is on the same line.
How to fix this?
index.php
<?php $go = isset($_GET['texto'])?$_GET['texto']:"primeira linha\nsegunda linha";?>
<form method="get">
<input name="texto" type="text" value="<?php echo $go ?>" size="100"/>
<input type="submit" value="Criar imagem" />
</form>
<img src="img.php?texto=<?php echo $go ?>" />
img.php
<?php
$tamfonte = 25;
$fonte = 'verdana.ttf';
$texto = $_GET['texto'];
$img = imagettfbbox($tamfonte, 0, $fonte, $texto);
$largura = "600";
$altura = "400";
$imagem = imagecreate($largura, $altura);
imagecolorallocate($imagem, 255, 255, 255);
$corfonte = imagecolorallocate($imagem, 0, 0, 0);
imagefttext($imagem, $tamfonte, 0, 0, abs($img[5]), $corfonte, $fonte, $texto);
header( 'Content-type: image/jpeg' );
imagejpeg($imagem, NULL, 100); ?>
@brasofilo - What I meant to go through $get was that if you replace the line $text = $_GET['text']; for that $text = "line1 n Linha2"; in the img.php file n will break the line and using oform in the get method the text is on the same line. this command "imagecreate( int_x size,int y_size);" has to do with GD the term in the perguta is because I used it is this!
– Rose