Jump to content

How do i put a line break on this code?

- - - - -

This topic has been archived. This means that you cannot reply to this topic.
8 replies to this topic

#1
lil-fino

lil-fino

    Newbie

  • Members
  • PipPip
  • 15 posts
I try /n but it doesnt work. I want to put a line break after "Generated by FluidCoding", so i can put my own text and leave that.

Thank u!




<?php
// Get the Ip
$ip = $_SERVER['REMOTE_ADDR'];

header("Content-type: image/png");

// Create an image width: 250, height: 40.
$im = @imagecreate(205, 40)
    or die("Cannot Initialize new GD image stream");
// Background Color = black
$background_color = imagecolorallocate($im, 0, 0, 0);
// Text Color = Red
$text_color = imagecolorallocate($im, 255, 0, 0);
// Print First line onto image
imagestring($im, 3, 10, 5,  "Your Ip is: ".$ip, $text_color);
// Print Second Line
imagestring($im, 3, 10, 5+imagefontheight(3), 
			"Generated by FluidCoding", $text_color);

imagepng($im);
// Free up memory
imagedestroy($im);

?>


#2
Rajesh

Rajesh

    Newbie

  • Members
  • Pip
  • 2 posts
Try This My Frend
Write <br>
Not \n
Like This: "Generated by FluidCoding<br>"
As I did In Your Example...........

Cheers up........
<?php
// Get the Ip
$ip = $_SERVER['REMOTE_ADDR'];

header("Content-type: image/png");

// Create an image width: 250, height: 40.
$im = @imagecreate(205, 40)
or die("Cannot Initialize new GD image stream");
// Background Color = black
$background_color = imagecolorallocate($im, 0, 0, 0);
// Text Color = Red
$text_color = imagecolorallocate($im, 255, 0, 0);
// Print First line onto image
imagestring($im, 3, 10, 5, "Your Ip is: ".$ip, $text_color);
// Print Second Line
imagestring($im, 3, 10, 5+imagefontheight(3),
"Generated by FluidCoding<br>", $text_color);

imagepng($im);
// Free up memory
imagedestroy($im);

?>

#3
Bioshox

Bioshox

    Programming Professional

  • Members
  • PipPipPipPipPip
  • 207 posts

<?php

// Get the Ip

$ip = $_SERVER['REMOTE_ADDR'];


header("Content-type: image/png");


// Create an image width: 250, height: 40.

$im = @imagecreate(205, 40)

    or die("Cannot Initialize new GD image stream");

// Background Color = black

$background_color = imagecolorallocate($im, 0, 0, 0);

// Text Color = Red

$text_color = imagecolorallocate($im, 255, 0, 0);

// Print First line onto image

imagestring($im, 3, 10, 5,  "Your Ip is: ".$ip, $text_color);

// Print Second Line

imagestring($im, 3, 10, 5+imagefontheight(3);

echo "<br>Generated by FluidCoding"; 

$text_color);


imagepng($im);

// Free up memory

imagedestroy($im);


?>



#4
lil-fino

lil-fino

    Newbie

  • Members
  • PipPip
  • 15 posts
It didn't work :crying:

#5
Bioshox

Bioshox

    Programming Professional

  • Members
  • PipPipPipPipPip
  • 207 posts
Your code look's weird to me anyway

$text_color); 

What bracket is that closing?

<?php
// Get the Ip
$ip = $_SERVER['REMOTE_ADDR'];

header("Content-type: image/png");

// Create an image width: 250, height: 40.
$im = @imagecreate(205, 40)
    or die("Cannot Initialize new GD image stream");
// Background Color = black
$background_color = imagecolorallocate($im, 0, 0, 0);
// Text Color = Red
$text_color = imagecolorallocate($im, 255, 0, 0);
// Print First line onto image
imagestring($im, 3, 10, 5,  "Your Ip is: ".$ip, $text_color);
// Print Second Line
imagestring($im, 3, 10, 5+imagefontheight(3), $text_color);

imagepng($im);
// Free up memory
imagedestroy($im);

echo "Generated by FluidCoding";

?>


#6
Orjan

Orjan

    Writes binary right handed and hex left handed

  • Moderators
  • 3,299 posts
You can't do an echo when outputting an image. that will be wrong output.

where would you like the line break? it looks like you try to write two lines already, shall it be three?
__________________________________________
I study Information Systems at Karlstad University when I'm not on CodeCall

#7
lil-fino

lil-fino

    Newbie

  • Members
  • PipPip
  • 15 posts
i just want to make another line after "Generated by FluidCoding"
can i make another echo or something?

#8
Orjan

Orjan

    Writes binary right handed and hex left handed

  • Moderators
  • 3,299 posts
you need to add a third line of imagestring:
i<?php

// Get the Ip

$ip = $_SERVER['REMOTE_ADDR'];


header("Content-type: image/png");


// Create an image width: 250, height: 40.

$im = @imagecreate(205, 40)

    or die("Cannot Initialize new GD image stream");

// Background Color = black

$background_color = imagecolorallocate($im, 0, 0, 0);

// Text Color = Red

$text_color = imagecolorallocate($im, 255, 0, 0);

// Print First line onto image

imagestring($im, 3, 10, 5,  "Your Ip is: ".$ip, $text_color);

// Print Second Line

imagestring($im, 3, 10, 5+imagefontheight(3), 

			"Generated by FluidCoding", $text_color);

imagestring($im, 3, 10, 5+(imagefontheight(3)*2), 

			"This is the third line", $text_color);

imagepng($im);

// Free up memory

imagedestroy($im);


?>
please note how I sat the third parameter to 5 + imagefontheight(3) * 2 so you really place it on row three
__________________________________________
I study Information Systems at Karlstad University when I'm not on CodeCall

#9
lil-fino

lil-fino

    Newbie

  • Members
  • PipPip
  • 15 posts
thanks man! its works and i learned something today :)