SitePoint Sponsor

User Tag List

Results 1 to 10 of 10
  1. #1
    SitePoint Enthusiast
    Join Date
    Nov 2007
    Posts
    40
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question how to close html tags with php

    hi i want to ask question about how to manage html tags in php, how to close html tags properly with html if any missing either opening or closing before sending to the browser it find any missing tag than put it properly and send it to browser, so our template not get out of its limit, because of the missing tag

  2. #2
    Guru in training bronze trophy SoulScratch's Avatar
    Join Date
    Apr 2006
    Location
    Maryland
    Posts
    1,838
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You shouldn't be using server-side to do this, but instead just validate using http://validator.w3.org/ as it'll be less error-prone and less overhead ( since you won't be doing the validating ).

    Alternatively you could use strict xhtml sent as application/xhtml+xml where you get a big yellow screen of death if anything is off.
    Cross browser css bugs

    Dan Schulz you will be missed

  3. #3
    SitePoint Enthusiast
    Join Date
    Nov 2007
    Posts
    40
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    that's ok but the problem is that im saving my content in the data base using fckeditor which is putting <p> tag in for each and every paragraph, in front end im splitting the that content for specific length these tags are got miss while split that's why im asking

  4. #4
    SitePoint Wizard silver trophy kyberfabrikken's Avatar
    Join Date
    Jun 2004
    Location
    Copenhagen, Denmark
    Posts
    6,157
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Sounds like you have a more fundamental problem there, but you could send you markup through html tidy, to fix it.

  5. #5
    SitePoint Enthusiast
    Join Date
    Nov 2007
    Posts
    40
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Thumbs up

    really thanks i can see that tidy i really helpful to solve my problem another thing is that will it work for only for php 5 or also work for php4 well thanks again for solving this problem.

  6. #6
    SitePoint Wizard silver trophy kyberfabrikken's Avatar
    Join Date
    Jun 2004
    Location
    Copenhagen, Denmark
    Posts
    6,157
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I think the tidy extension existed for php4, although I'm not entirely sure. Alternatively you can call it over the shell, if you have access to that on your server.

  7. #7
    SitePoint Wizard lorenw's Avatar
    Join Date
    Feb 2005
    Location
    was rainy Oregon now sunny Florida
    Posts
    1,094
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by SoulScratch View Post
    Alternatively you could use strict xhtml sent as application/xhtml+xml where you get a big yellow screen of death if anything is off.
    If you send xhtml as application/xhtml+xml in a php header, IE users get a download prompt.

    setting application/xhtml+xml in meta tags is pointless because the server has already sent the output as text/html and you can not change that with meta tags.

    Back to the question, why would you be missing closing tags and that should really be fixed in the outputted code. w3c is your friend.

    Cheers.
    What I lack in acuracy I make up for in misteaks

  8. #8
    Guru in training bronze trophy SoulScratch's Avatar
    Join Date
    Apr 2006
    Location
    Maryland
    Posts
    1,838
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by lorenw View Post
    If you send xhtml as application/xhtml+xml in a php header, IE users get a download prompt.

    setting application/xhtml+xml in meta tags is pointless because the server has already sent the output as text/html and you can not change that with meta tags.
    Well, it's not specific to PHP but any http header where the Content-Type is application/xhtml+xml ( or something xhtml-esque ).

    I never mentioned anything about meta tags whatsoever, but I do agree that he should validate the output and/or use Tidy.
    Cross browser css bugs

    Dan Schulz you will be missed

  9. #9
    SitePoint Wizard lorenw's Avatar
    Join Date
    Feb 2005
    Location
    was rainy Oregon now sunny Florida
    Posts
    1,094
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    SoulScratch,

    Sorry, no offence at all, I am on a vendetta against xhtml because very few people use it as it's designed to be used and most all pages that use it have a meta tag with application/xhtml+xml and think it is being served as xhtml.

    IE doesnt even recognize the xhtml doctype, you could replace xhtml with huh and IE would render it the same way.
    IE doesnt understand <img src="img.jpg" /> or <br /> and goes into error correcting mode to display the image or br.

    the alternative would be html strict, That is what ie understands.

    Sorry for the rant and if ie worked like ff I will shut up and fully endorse xhtml.

    MS just doesnt see the value and we are stuck with html strict.

    just my .002 cent (economy's not that good) rant
    What I lack in acuracy I make up for in misteaks

  10. #10
    Guru in training bronze trophy SoulScratch's Avatar
    Join Date
    Apr 2006
    Location
    Maryland
    Posts
    1,838
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I don't really favor xhtml either - if you've seen any of my posts or snippets on the HTML/CSS forums.
    Cross browser css bugs

    Dan Schulz you will be missed


Tags for this Thread

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
  •