467,926 Members | 1,473 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 467,926 developers. It's quick & easy.

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>

Mar 9 '06 #1
  • viewed: 2062
Share:
4 Replies
su******@europe.com wrote in news:1141939601.672057.138520
@j33g2000cwa.googlegroups.com:
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?


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

me thinks you are very, very confused.
Mar 9 '06 #2
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

su******@europe.com wrote:
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>

Mar 9 '06 #3
eval(); is evil. You should use it only in extreme situations.

You can also try here document syntax.

http://de.php.net/echo

su******@europe.com wrote:
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>


Mar 10 '06 #4
d
"Johannes Matjeschk" <Jo****************@googlemail.com> wrote in message
news:11*********************@j33g2000cwa.googlegro ups.com...
eval(); is evil. You should use it only in extreme situations.

You can also try here document syntax.

http://de.php.net/echo
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
su******@europe.com wrote:
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>

Mar 10 '06 #5

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

4 posts views Thread by comcast news | last post: by
2 posts views Thread by Joe | last post: by
10 posts views Thread by pak.andrei | last post: by
4 posts views Thread by Jeff | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.