Topic: Display php-code?
How have you done for displaying php-code in the posts, instead of running it?
I have that problem in my articles.
Please tell me!
You are not logged in. Please login or register.
PunBB Forums → PunBB 1.2 troubleshooting → Display php-code?
How have you done for displaying php-code in the posts, instead of running it?
I have that problem in my articles.
Please tell me!
I'm not sure I understand what you mean. If you just output PHP code it won't run:
echo '<?php echo "bajs" ?>';
will not print out bajs. It will print out
<?php echo "bajs" ?>
Am I missing something?
"bajs" is not a nice word!
I'll test what you just wrote. I really hope that it is not that easy!
for me displayes
echo "<? echo \"test\"; ?>";
nothing.
What's wrong..?? :confused:
What is the problem? I think you have to tell me a little more about what you want to do.
I have text (and sometimes php-code) in a database.
I want to display the text and code, not run it.
Do you understand?
If I write:
echo "hej";
it displays "hej".
But if i write echo "<? echo\"hej\"; ?>";
it doesn't display <? echo "hej"; ?> it displays nothing!
Do you have any idea of what can be wrong?
Thank you!
Try running htmlspecialchars() on the text before outputting it.
Ah, now everything is displayed in text. Even the <br>'s. How can I get around that?
try running htmlspecialchars(str_replace("<br>", "\n", $text)) or something?
Well, you have to run htmlspecialchars() on the text before you convert \n to <br>.
Now I got it right!
I used:
get_article = stripslashes($article->get_text());
$get_article = htmlspecialchars($get_article);
echo nl2br($get_article);
Thanks guys!
PunBB Forums → PunBB 1.2 troubleshooting → Display php-code?
Powered by PunBB, supported by Informer Technologies, Inc.