Results 1 to 7 of 7

Thread: How to avoid DOCTYPE, header ...

  1. #1
    Join Date
    Jun 2006
    Location
    Austrian in Taiwan
    Beans
    Hidden!
    Distro
    Ubuntu 16.04 Xenial Xerus

    How to avoid DOCTYPE, header ...

    I don't know how to call it, I don't know where to ask, ... please give me a hint


    My problem:
    I should answer with a php program JUST text
    No doctype, head, body, ... just a simple text.


    How to do? Where to ask?
    I am from the government, I am here to help you! Just ask!
    And don't expect more to be happen than with any other government!
    ---
    Ubuntu 15.10 on AMD64

  2. #2
    Join Date
    Sep 2006
    Beans
    8,627
    Distro
    Ubuntu 14.04 Trusty Tahr

    Re: How to avoid DOCTYPE, header ...

    If you are serving up plain text, you can set the MIME type to "plain/text"

    Code:
    <?php
    header('Content-Type: text/plain');
    echo ("Hello, world!");
    ?>
    See the function header()
    http://www.php.net/manual/en/function.header.php

  3. #3
    Join Date
    Jun 2006
    Location
    Austrian in Taiwan
    Beans
    Hidden!
    Distro
    Ubuntu 16.04 Xenial Xerus

    Re: How to avoid DOCTYPE, header ...

    It did not work for me:

    Now it displays:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">

    <head>
    <title>title</title>
    <meta http-equiv="content-type" content="text/html;charset=utf-8" />
    <meta name="generator" content="Geany 0.21" />
    <link rel="stylesheet" type="text/css" href="mnp.css" />
    </head>

    <body>
    MyText
    </BODY>
    </HTML>
    But I need only:
    MyText
    I am from the government, I am here to help you! Just ask!
    And don't expect more to be happen than with any other government!
    ---
    Ubuntu 15.10 on AMD64

  4. #4
    Join Date
    Sep 2006
    Beans
    8,627
    Distro
    Ubuntu 14.04 Trusty Tahr

    Re: How to avoid DOCTYPE, header ...

    You might double-check the actual content of the file. It looks like the document itself is HTML. Some of the HTML markup there implies that the page was manually written as HTML, not as some artifact of PHP. What is the output of the file if you use a terminal window and open up the file using "cat" or "less" ?

  5. #5
    Join Date
    Jun 2006
    Location
    Austrian in Taiwan
    Beans
    Hidden!
    Distro
    Ubuntu 16.04 Xenial Xerus

    Re: How to avoid DOCTYPE, header ...

    It is a php program and it calculates some values, which I should display in PURE text.

    When I just "echo $text" it looked fine, but the other machine sees all the other code, ...
    I can now make it "visible" with your methode, but I want to avoid it all together. How can I do that?

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">

    <head>
    <title>title</title>
    <meta http-equiv="content-type" content="text/html;charset=utf-8" />
    <link rel="stylesheet" type="text/css" href="mnp.css" />
    </head>

    <body>
    Hello, world!<p>
    </BODY>
    </HTML>
    I am from the government, I am here to help you! Just ask!
    And don't expect more to be happen than with any other government!
    ---
    Ubuntu 15.10 on AMD64

  6. #6
    Join Date
    Jun 2006
    Location
    Austrian in Taiwan
    Beans
    Hidden!
    Distro
    Ubuntu 16.04 Xenial Xerus

    Re: How to avoid DOCTYPE, header ...

    I solved it: Just don't write the HTML tags, ...
    It was simple too easy to think of that!!!
    I am from the government, I am here to help you! Just ask!
    And don't expect more to be happen than with any other government!
    ---
    Ubuntu 15.10 on AMD64

  7. #7
    Join Date
    Sep 2006
    Beans
    8,627
    Distro
    Ubuntu 14.04 Trusty Tahr

    Re: How to avoid DOCTYPE, header ...

    Quote Originally Posted by ELMIT View Post
    I solved it: Just don't write the HTML tags, ...
    It was simple too easy to think of that!!!
    Glad it's solved. That's what I tried to express in #4 above. It was this line which gave it away:

    Code:
     <meta name="generator" content="Geany 0.21" />
    Someone had used Geany to write HTML markup in the file.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •