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 9279389
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T17:37:22+00:00 2026-06-18T17:37:22+00:00

I have this php page that gets values from a database. From another script

  • 0

I have this php page that gets values from a database. From another script on another server, I make a http request to that page and grab the result. The result must be a clean TXT, something like a phrase for example, or a number, or whatever.

When I debug the results I get I see something like this (suppose the answer I was expecting was +OK:server ready+):

+OK:server ready+
1.1 200 OK

I am getting this extra line.

If I make a direct request using a browser, I see +OK:server ready+ but when I look at the page source of that result page I see this:

<html>
<head>
  <style type="text/css"></styles>
</head>
<body>
  <pre style="word-wrap: break-word; white-space: pre-wrap;">+OK:server ready+</pre>
</body>
</html>

Apparently the browser is adding this, right?

Anyway, the code that generates the line I want is this:

header('Content-Type: text/plain');
echo("+" . $resultFromServer . "+");

is this the correct way to send out a clean text, without any formatting, tag, whatever, from PHP?

thanks.

  • 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-18T17:37:23+00:00Added an answer on June 18, 2026 at 5:37 pm

    Encoding is missing in your header:

    header('Content-type: text/plain; charset=utf-8');
    

    But it should work fine without it as long as you send only ASCII characters.

    Browser should not add any html code, but I’ve seen some PHP frameworks that messed up non-standard output. Check if there is any extra output processing in your application. But if you have only that two lines in your PHP script, it must work.

    Btw, echo is not a function and it accepts multiple arguments, so you do not have to concatenate strings with dot operator – echo 'a', $b, 'c'; is much faster.

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

Sidebar

Related Questions

So I have a php page that gets data from database and displays a
I have a php page that gets a value from $_GET and according to
I have very simple form that gets values in JSON format from searchAlbum.php .
i have this simple code to load data from other php page using get
I have this jQuery script var dataString = class_id=+class_id; $.ajax({ type: POST, url: page.php,
I have this page: http://www.thedome.it/cmsms/index.php?page=alla-spina I'd like to send a newsletter to subscribers every
I have my site as localhost/tutorials/rewrite/news.php on this page are titles from news articles
I have an index.html page that makes an AJAX request to a PHP page;
So I have an array that gets created from a php loop that looks
I have a working script that passes a value from a popup page to

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.