Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    Regular Coder
    Join Date
    Jun 2010
    Posts
    163
    Thanks
    10
    Thanked 0 Times in 0 Posts

    PHP is displayed to page because Doctype = Strict

    I am working on a Contact Form in my .php file. I have always worked with loose doctypes, however, today I am using strict. I have my php above my html, and none of the code runs. Instead, it just displays some of the Echos to the page (these aren't even called yet). Also, in my form, I have the following:

    <INPUT NAME="Name" SIZE="30" value="<?php echo $Name; ?>">

    On the page inside the field, it is displaying: <?php echo $Name; ?>

    What is going on here and how can I fix this issue?

    Yes, the pages are .php
    Here is the doctype:

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

    Any input appreciated

  • #2
    Senior Coder
    Join Date
    Sep 2010
    Posts
    1,996
    Thanks
    15
    Thanked 233 Times in 233 Posts
    Doctype strict is, well 'strict', it doesn't tolerate any bad markup, by it's definition, this is bad: <INPUT NAME, should be all lower case inside tags, so for starters, run the page through the validator, also you may have a missing " or ' here or there. And read up on the allowed markup a bit. And that doesn't account for how browsers render it, some may be more tolerant than others.

  • #3
    Senior Coder
    Join Date
    Jul 2009
    Location
    South Yorkshire, England
    Posts
    2,318
    Thanks
    6
    Thanked 304 Times in 303 Posts
    Your problem has nothing to do with the doctype in use. If php code is being displayed raw, you have a syntax error somewhere. Enable error reporting and see what the problem is. Also, as DrDos mentioned, the XHTML strict doctype requires that all tags are in their correct case. XML is case sensitive. It's only the fact that you are obviously serving it as text/html instead of its correct mimetype which is allowing it to display at all. The browser would be halting during parsing otherwise.
    Last edited by MattF; 11-28-2010 at 08:47 AM.


  •  

    Posting Permissions

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