SitePoint Sponsor

User Tag List

Results 1 to 9 of 9
  1. #1
    SitePoint Member
    Join Date
    Jul 2006
    Posts
    6
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Exclamation php rendering last > as html entity

    I have written some php which renders out javascript. To make this validate I wrapped the js with cdata like this:

    //<![CDATA[
    //]]>

    The first bit is rendered ok, however the last greater than is rendered out as &gt;.

    I have no idea why this is happeneing. Can anyone help?

    Thanks,

    Mark

  2. #2
    dooby dooby doo silver trophybronze trophy
    spikeZ's Avatar
    Join Date
    Aug 2004
    Location
    Manchester UK
    Posts
    13,806
    Mentioned
    158 Post(s)
    Tagged
    3 Thread(s)
    Hi Mark and welcome to the forums

    What happens if you remove the // before the <! and the ]] ?
    it might be that the parser is reading it as a commented line......

    (it might not mean that but hey, worth a thought!)
    Mike Swiffin - Community Team Advisor
    Only a woman can read between the lines of a one word answer.....

  3. #3
    SitePoint Member
    Join Date
    Jul 2006
    Posts
    6
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi, thanks, its good to be here!

    Hmm, good point. That didnt fix it, but i tried putting a space in between the ]] which fixed the >. However, the pages dont validate because of the space. the code is in a string that is returned. Getting there.

  4. #4
    dooby dooby doo silver trophybronze trophy
    spikeZ's Avatar
    Join Date
    Aug 2004
    Location
    Manchester UK
    Posts
    13,806
    Mentioned
    158 Post(s)
    Tagged
    3 Thread(s)
    Can you post the string that is output Mark?
    Mike Swiffin - Community Team Advisor
    Only a woman can read between the lines of a one word answer.....

  5. #5
    SitePoint Member
    Join Date
    Jul 2006
    Posts
    6
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Sure, here is the basic code:

    $list_string .= '
    <script type="text/javascript">
    //<![CDATA[

    //]]>
    </script>';

    and this is what is rendered:

    <script type="text/javascript">
    //<![CDATA[

    //]]&gt;
    </script>

  6. #6
    SitePoint Enthusiast Cborrow's Avatar
    Join Date
    Apr 2005
    Posts
    57
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Try putting it into double quotes and escape the others with \" to see if it changes anything.

    It might not do anything but it could always be a possibility for it.

  7. #7
    SitePoint Member
    Join Date
    Jul 2006
    Posts
    6
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Actually, I better mention that it is used within Wordpress. That might have something to do with it.

  8. #8
    SitePoint Member
    Join Date
    Jul 2006
    Posts
    6
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Sorted. I dont know why this was happening, instead of returning the string I used echo instead and this fixed it. Thanks for the help.

  9. #9
    dooby dooby doo silver trophybronze trophy
    spikeZ's Avatar
    Join Date
    Aug 2004
    Location
    Manchester UK
    Posts
    13,806
    Mentioned
    158 Post(s)
    Tagged
    3 Thread(s)
    Glad you got it sorted Mark
    Mike Swiffin - Community Team Advisor
    Only a woman can read between the lines of a one word answer.....


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
  •