Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7731053
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T06:22:59+00:00 2026-06-01T06:22:59+00:00

I previously asked why \n in a string was not returning a line break.

  • 0

I previously asked why \n in a string was not returning a line break.

This was because the string needed to be in Double Quotes. (Thanks @Juhana !)

Now I am using GET so I can change the text string in the URL

$text = $_GET["msg"];

And the URL:

http://www.mywebsite.co.uk/image.php?msg=Something\nElse

Results in outputted text “Something\\nElse”
But what I want is a line break like this:
“Something
Else”

How come the text still has those two backslashes?
Am I wrong to think that because the “msg” is in Double Quotes it should create a line break?

thanks

EDIT full PHP code

<?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);
?>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T06:23:01+00:00Added an answer on June 1, 2026 at 6:23 am

    I think magic_quotes are ON on configuration. Thats why adds slash automatic when there special character like \ (backslash).

    if(get_magic_quotes_gpc())
        $text = stripslashes($_GET['msg']);
    else 
        $text = $_GET['msg'];
    

    But if you going to use these in live application, you need more validation for avoid
    security issues. If you sending text with special characters or html tags better use POST method or at least hash code and revese. Your url:

    http://url.com/image.php?msg=<?php echo base64_encode('your text\n test');>
    

    And in image.php

    $text = isset($_GET['msg']) ? $_GET['msg'] : 'default text';
    $text = base64_decode($_GET['msg']);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have seen this question asked previously but can not find a clear explanation
I previously asked a question about chaining conditions in Linq To Entities. Now I
This is an extension of a question I previously asked here . Long story
I know this question was asked previously and the reply was to override onPrepareContextMenu()/onCreateContextMenu().
This is related to a question I've asked previously: Calling Javascript function after loading
difficult to look this up if it has been asked previously since I don't
Previously I've asked about inserting a column into a dataset . I now have
I previously asked a similar question on this topic a while back and got
So I've previously asked this question: How do I point a socket to the
I found this question asked previously but it contained bad examples and no true

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.