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 8 of 8
  1. #1
    New Coder
    Join Date
    Nov 2006
    Posts
    94
    Thanks
    0
    Thanked 0 Times in 0 Posts

    using php and html together

    I am using php and html in the same document. I am saving it as a .php. Do I still use the <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    "http://www.w3.org/TR/html4/loose.dtd"> even with php or is there a different heading.

  • #2
    Regular Coder Tyree's Avatar
    Join Date
    Sep 2003
    Posts
    254
    Thanks
    0
    Thanked 0 Times in 0 Posts
    PHP doesn't care what doctype you declare in the html. HTML, XHTML... doesn't matter. PHP is server-side, HTML is client-side.

  • #3
    New Coder
    Join Date
    Nov 2006
    Posts
    94
    Thanks
    0
    Thanked 0 Times in 0 Posts
    The problem is that my script seems to work just fine but none of my html is displayed, and I don't know why. Can apache only display the php or what? It is like it ignores my html.
    Last edited by phpnewb; 12-01-2006 at 01:20 PM.

  • #4
    New Coder
    Join Date
    Nov 2006
    Posts
    94
    Thanks
    0
    Thanked 0 Times in 0 Posts
    if there is anyone that can answer my question, the help would be much appreciated

  • #5
    Senior Coder CFMaBiSmAd's Avatar
    Join Date
    Oct 2006
    Location
    Denver, Colorado USA
    Posts
    3,092
    Thanks
    2
    Thanked 322 Times in 314 Posts
    If a request is made for a page that ends in .htm/html/txt... (non server side PHP/ASP/NET...) a web server basically reads the file and sends the content to the browser.

    If a request is made for a .php file (assuming the web server is configured to pass .php files to the php parser - the exact extension does not matter, you could configure this to be .abc if you wanted) the PHP language parser is invoked to read the file and attempt to parse it. Any content that is not within php tags, is simply output to the browser. Content that is within php tags gets parsed and interpreted as php code.

    When you mix HTML content and php code, so long as there are proper opening and closing php tags surrounding the php code, it will work.

    PHP code sends output to the browser using echo/print/print_r statements. The end result that reaches the browser needs to be valid HTML code. Therefore, you need to output a doctype that matches the resultant HTML code.

    If you have some specific code that is not working, you would need to post it.
    If you are learning PHP, developing PHP code, or debugging PHP code, do yourself a favor and check your web server log for errors and/or turn on full PHP error reporting in php.ini or in a .htaccess file to get PHP to help you.

  • #6
    New Coder
    Join Date
    Nov 2006
    Posts
    94
    Thanks
    0
    Thanked 0 Times in 0 Posts
    the scripting i was asking about is on this page
    http://www.codingforums.com/showthre...=101846&page=2

  • #7
    New Coder
    Join Date
    Nov 2006
    Posts
    94
    Thanks
    0
    Thanked 0 Times in 0 Posts
    thx the problem has been solved

  • #8
    New to the CF scene
    Join Date
    Dec 2006
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by Tyree View Post
    PHP doesn't care what doctype you declare in the html. HTML, XHTML... doesn't matter. PHP is server-side, HTML is client-side.
    that's what makes php so awesome! its flexibilty and robustness. I think that its because of this we've seen the explosion of the use of php in the recent few last years. wouldn't you agree?


  •  

    Posting Permissions

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