Page 1 of 1

[Solved] noring tags in a string

Posted: Tue Sep 08, 2009 6:35 pm
by frozenarmageddon
I am pretty sure its the wrong place to ask this question in... but...

I am trying to set a string to a variable.

Code: Select all

<?php
$message = "bla bla bla bla";
echo "The message is: $message <br/>";
?>
And it works all fine, but for example if I try to make:

Code: Select all

<?php
$message = "bla bla o|-<bla bla";
echo "The message is: $message <br/>";
?>
it doesn't echos it, it stops before the <
I understand its because it is an HTML tag starter, And I am no big expert in HTML...
I was searching for a solution for like 2 and a half hours now, and I gave up and decided to ask you guys, is there a way to ignore the tag starter when I echo it?

Oh, and second question, its pretty obvius, im just making sure:
The escape backslash ["\"] won't be part of a string?
Like if I count the charecters in the string "It/'s a beautiful day" it will result in 20 characters? or 21 (including the /)?

~dammit, in 3 hours I need to wake up for school, what am I doing?! T_T~

Re: Ignoring tags in a string

Posted: Tue Sep 08, 2009 6:58 pm
by Eric!
Do this:

Code: Select all

$message = "bla bla o|-<bla bla";
echo "The message is: ".htmlentities($message)." <br/>";
This will change < into the &lt for html display. Now you can go to bed.

Re: Ignoring tags in a string

Posted: Tue Sep 08, 2009 11:52 pm
by frozenarmageddon
lol actually I fell asleep right after I posted it, woke up by accident 20 minutes ago -- one and a half hour from the time I should have woke up ^^ but that's ok, I didn't miss school, I got a hour left to get ready :P
Anyway, it worked, thanks <3