HTML code in eval

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • sunnyboy@europe.com

    #1

    HTML code in eval

    Hi

    I'm currently trying to put some HTML code into a variable and to use
    it later.
    Any ideas, why TEST1 in the following example displays a link, while
    TEST2 only displays a text?

    Any help appreciated.

    <html>
    <head>
    </head>

    <body>

    <!-- TEST1 -->
    <a href=\"www.test .com\">this is test1</a>

    <br><br>

    <!-- TEST2 -->
    <?
    $teststr="?><a href=\"www.test .com\">this is test2</a><?php";
    eval($teststr);
    ?>

    </body>
    </html>

  • Good Man

    #2
    Re: HTML code in eval

    sunnyboy@europe .com wrote in news:1141939601 .672057.138520
    @j33g2000cwa.go oglegroups.com:
    [color=blue]
    > Hi
    >
    > I'm currently trying to put some HTML code into a variable and to use
    > it later.
    > Any ideas, why TEST1 in the following example displays a link, while
    > TEST2 only displays a text?[/color]

    your HTML code is totally screwed up. whats with the \" stuff outside of
    PHP?!??

    me thinks you are very, very confused.

    Comment

    • Scott

      #3
      Re: HTML code in eval

      I'm not sure I understand why you're trying to use eval in this
      situation. Wouldn't this give you the result you're after?

      $teststr = '<a href="www.test. com">This is test 2</a>';
      echo $teststr;

      Scott

      sunnyboy@europe .com wrote:[color=blue]
      > Hi
      >
      > I'm currently trying to put some HTML code into a variable and to use
      > it later.
      > Any ideas, why TEST1 in the following example displays a link, while
      > TEST2 only displays a text?
      >
      > Any help appreciated.
      >
      > <html>
      > <head>
      > </head>
      >
      > <body>
      >
      > <!-- TEST1 -->
      > <a href=\"www.test .com\">this is test1</a>
      >
      > <br><br>
      >
      > <!-- TEST2 -->
      > <?
      > $teststr="?><a href=\"www.test .com\">this is test2</a><?php";
      > eval($teststr);
      > ?>
      >
      > </body>
      > </html>
      >[/color]

      Comment

      • Johannes Matjeschk

        #4
        Re: HTML code in eval

        eval(); is evil. You should use it only in extreme situations.

        You can also try here document syntax.



        sunnyboy@europe .com wrote:[color=blue]
        > Hi
        >
        > I'm currently trying to put some HTML code into a variable and to use
        > it later.
        > Any ideas, why TEST1 in the following example displays a link, while
        > TEST2 only displays a text?
        >
        > Any help appreciated.
        >
        > <html>
        > <head>
        > </head>
        >
        > <body>
        >
        > <!-- TEST1 -->
        > <a href=\"www.test .com\">this is test1</a>
        >
        > <br><br>
        >
        > <!-- TEST2 -->
        > <?
        > $teststr="?><a href=\"www.test .com\">this is test2</a><?php";
        > eval($teststr);
        > ?>
        >
        > </body>
        > </html>[/color]

        Comment

        • d

          #5
          Re: HTML code in eval

          "Johannes Matjeschk" <Johannes.Matje schk@googlemail .com> wrote in message
          news:1141980306 .543975.27770@j 33g2000cwa.goog legroups.com...[color=blue]
          > eval(); is evil. You should use it only in extreme situations.
          >
          > You can also try here document syntax.
          >
          > http://de.php.net/echo[/color]

          They should just rename it to evil() and get it over with. "If eval() is
          ever the answer, you've screwed up the question" :-P
          [color=blue]
          > sunnyboy@europe .com wrote:[color=green]
          >> Hi
          >>
          >> I'm currently trying to put some HTML code into a variable and to use
          >> it later.
          >> Any ideas, why TEST1 in the following example displays a link, while
          >> TEST2 only displays a text?
          >>
          >> Any help appreciated.
          >>
          >> <html>
          >> <head>
          >> </head>
          >>
          >> <body>
          >>
          >> <!-- TEST1 -->
          >> <a href=\"www.test .com\">this is test1</a>
          >>
          >> <br><br>
          >>
          >> <!-- TEST2 -->
          >> <?
          >> $teststr="?><a href=\"www.test .com\">this is test2</a><?php";
          >> eval($teststr);
          >> ?>
          >>
          >> </body>
          >> </html>[/color]
          >[/color]


          Comment

          Working...