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

  • Home
  • SEARCH
  • 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 7072559
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T05:49:24+00:00 2026-05-28T05:49:24+00:00

I have to pass a string to a form. I want to use a

  • 0

I have to pass a string to a form.
I want to use a mix of $_GET and $_POST in the following way:

 <?php $string="bla bla bla".$some_other_string."bla bla".$some_other_string2."\n"; ?>

 <form action="this_page.php?string=<?php echo $string?>" method="post" name="name">

 </form>

Please note the \n in the string.
When I get the $_GET("string") (or $_REQUEST("string"), it happens the following: the php parser get the \n as a string. So he put it into the string as I had coded: \\\n and it’s not the result I want. I want simply a inner \n in a php string.

Please can you explain me why this behaviour happens, without complaining that it’s not the best way to pass a string (I suppose it isn’t, but today I had an issue and I wanted to manage it by passing the string this way)?

Ps: I have to use the \n and not the html <br /> because I have to let php write into a file.

  • 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-05-28T05:49:25+00:00Added an answer on May 28, 2026 at 5:49 am

    Advice: You probably should think about putting this into a hidden field

    Answer: But if you are going to put it into action as a GET parameter, then you need to urlencode the string:

    <form action="this_page.php?string=<?php echo urlencode($string); ?>" method="post" name="name">
    

    That way – any non-alphanumeric characters will be url safe (think about what might happen if $string contained a ? or a # or an = ).

    PHP automatically decodes GET parameters when loading them into the $_GET array – so your newline should be preserved at that point.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following scenario where I want to pass in string and a
i have a NSData object. I want to convert it to a string, pass
I have a rest webservice which can accept a string. I want to pass
Hi i want to use windows form application in way like an api from
I'm trying to pass a string to chdir(). But I always seem to have
If I have the value 0.0042 returned and I pass this to: string.Format({0:C},....); It
I have a dynamic query string that I need to pass via an .htaccess
So I have a flashobject which I need to pass a formatted DateTime string
Let's say that I have this string: s = '<p>Hello!</p>' When I pass this
I have form1 passing a query string parameter(param1) to form2. I pass param1=true from

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.