Ранее я спрашивал, почему \ n в строке не возвращает разрыв строки.
Это потому, что строка должна быть в двойных кавычках. (Спасибо @Juhana!)
Теперь я использую GET, чтобы я мог изменить текстовую строку в URL
$text = $_GET["msg"];
И URL:
http://www.mywebsite.co.uk/image.php?msg=Something\nElse
В результате выводится текст "Something \\ nElse"
Но я хочу вот такой разрыв строки:
«Что-то
Остальное "
Как получилось, что в тексте остались эти две обратные косые черты?
Я ошибаюсь, думая, что, поскольку "msg" находится в двойных кавычках, это должно создать разрыв строки?
спасибо
РЕДАКТИРОВАТЬ полный код PHP
<?php
// Set the content-type
header ('Content-Type: image / png');
// Create the image
$im = imagecreatetruecolor(400, 100); //image big enough to display two lines
// Create some colors
$black = imagecolorallocate($im, 0, 0, 0);
imagefilledrectangle($im, 0, 0, 399, 29, $white);
// The text to draw
//$text = 'Testing\ntesting'; using SINGLE quotes like this results \\n
//$text = "Testing\ntesting"; using DOUBLE quotes like this results in line break
$text = $_GET["msg"];
// Replace path by your own font path
$font = 'arial.ttf';
// Add the text
imagettftext($im, 20, 0, 10, 20, $black, $font, $text);
// Using imagepng() results in clearer text compared with imagejpeg()
imagepng($im);
imagedestroy($im);
?>