Slashes in HTML - problem?!

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Vektor

    Slashes in HTML - problem?!

    Hi there!

    PHP version is 4.2.2

    Sometimes my PHP page loads like this:

    <body bgcolor=\"#FFFF FF\" text=\"#000000\ " leftmargin=\"0\ " topmargin=\"0\"
    marginwidth=\"0 \" marginheight=\" 0\" bottommargin=\" 0\">
    <table height=\"100%\" width=\"770\" border=\"0\" cellspacing=\"0 \"
    cellpadding=\"0 \" align=\"center\ ">
    <tr valign=\"top\" height=\"10\">
    <td>
    <table width=\"100%\" border=\"0\" cellspacing=\"0 \" cellpadding=\"0 \">
    <tr valign=\"top\">

    and page is of course displayed wrong.

    However, when I refresh it, I simply get normal view (without any
    backslashes before "):

    <body bgcolor="#FFFFF F" text="#000000" leftmargin="0" topmargin="0"
    marginwidth="0" marginheight="0 " bottommargin="0 ">
    <table height="100%" width="770" border="0" cellspacing="0" cellpadding="0"
    align="center">
    <tr valign="top" height="10">
    <td>
    <table width="100%" border="0" cellspacing="0" cellpadding="0" >
    <tr valign="top">


    What this can be? Sometimes when I refresh it - it shows fine, then wrong,
    then wrong, then fine, then wrong, then fine...

    I really don't understand why this is happening. Any help?

    TIA.

    --
    V.


  • Nick Howes

    #2
    Re: Slashes in HTML - problem?!

    Vektor wrote:[color=blue]
    > Hi there!
    >
    > PHP version is 4.2.2
    >
    > Sometimes my PHP page loads like this:
    >
    > <body bgcolor=\"#FFFF FF\" text=\"#000000\ " leftmargin=\"0\ " topmargin=\"0\"
    > marginwidth=\"0 \" marginheight=\" 0\" bottommargin=\" 0\">
    > <table height=\"100%\" width=\"770\" border=\"0\" cellspacing=\"0 \"
    > cellpadding=\"0 \" align=\"center\ ">
    > <tr valign=\"top\" height=\"10\">
    > <td>
    > <table width=\"100%\" border=\"0\" cellspacing=\"0 \" cellpadding=\"0 \">
    > <tr valign=\"top\">
    >[/color]

    I don't know why it works sometimes but doesn't sometimes, but I guess
    that you're printing all this using a PHP print() statement, eg
    print("<body bgcolor\"#fffff f\">");

    it's easier to just break out of the code if you're printing a lot of
    html in one go. If you need to insert some php variable in the middle
    then you can just do something like <img src="<?= filePath ?>">

    you can still use it to print html conditionally, eg

    if (variable < 5)
    {
    ?>
    <p>the variable is less than "5", so this html is printing and I
    don't need to escape anything.</p>
    <?
    }

    Comment

    • Matthias Esken

      #3
      Re: Slashes in HTML - problem?!

      Nick Howes schrieb:
      [color=blue]
      > I don't know why it works sometimes but doesn't sometimes, but I guess
      > that you're printing all this using a PHP print() statement, eg
      > print("<body bgcolor\"#fffff f\">");[/color]

      The easier way:
      print("<body bgcolor='#fffff f'>");

      Regards,
      Matthias

      Comment

      • Karl Heinz Marbaise

        #4
        Re: Slashes in HTML - problem?!

        Hi Matthias,

        [...][color=blue]
        > The easier way:
        > print("<body bgcolor='#fffff f'>");[/color]
        But ' is not allowed based on HTML standards AFAIK...isn't it?

        kind regards.
        Karl Heinz
        --
        Software Entwicklungs- und Beratungs Service http://www.soebes.de
        Dipl.Ing.(FH) Karl Heinz Marbaise email: info@soebes.de
        Tel.: +49 (0) 241 / 16 91 210 ICQ#: 135949029

        Comment

        • Matthias Esken

          #5
          Re: Slashes in HTML - problem?!

          Karl Heinz Marbaise schrieb:
          [color=blue]
          > Hi Matthias,
          >
          > [...][color=green]
          >> The easier way:
          >> print("<body bgcolor='#fffff f'>");[/color]
          > But ' is not allowed based on HTML standards AFAIK...isn't it?[/color]

          It is!

          We had a nice discussion in de.comm.infosys tems.www.authoring.misc about
          that. The discussion stopped immediatley when someone look at the
          documenation and tried the validator at http://validator.w3.org. :-)

          Regards,
          Matthias

          Comment

          Working...