Results 1 to 3 of 3

Thread: Hiding PHP for W3C validation....?

  1. #1
    Join Date
    May 2006
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Hiding PHP for W3C validation....?

    Hi,
    I'm trying to validate my XHTML site but I have some PHP on all the pages which is getting in the way, its just a small script which takes the time and date from the server and adjusts it to my correct time zone and then prints it on the screen.
    It looks like this:

    <?php

    $timeadjust = (10800);

    $todaysdate = date ('l F j, Y <br> g:i a', time() - $timeadjust);

    print $todaysdate;

    ?>

    When I try to validate I get these 3 errors:

    1. Error Line 79 column 25: character "," not allowed in attribute specification list.
    2. Error Line 79 column 25: element "bSun" undefined.
    3. Error Line 80 column 5: end tag for "bSun" omitted, but OMITTAG NO was specified.

    Obviously these errors are resulting from the HTML code which is generated by the PHP script when it retrieves the date and time because the "bSun" does not appear on the php document at all.

    SO....long story--->short....how do I escape the PHP for validation and still be able to use the PHP to generate date and time? because I tried <[CDATA[ ]]> tags and <!-- --> tags and that didnt work, it didnt allow the PHP to be seen at all. Thanks in advance to anyone who can help.

    Edman

  2. #2
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    Obviously these errors are resulting from the HTML code which is generated by the PHP script when it retrieves the date and time because the "bSun" does not appear on the php document at all.
    The problem is that the "r" is being parsed as a special character in the date string. Also, you're using XHTML, so you need to end that linebreak. Try:
    Code:
    <?php
      $timeadjust = 10800;
      $etime = time() - $timeadjust;
      $todaysdate = date('l F j, Y ', $etime) . '<br />' . date(' g:i a', $etime);
      echo($todaysdate);
    ?>
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  3. #3
    Join Date
    May 2006
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Twey,

    THANX! You rule. No...seriously.

    edman

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
  •