Can't put <> in variable?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
signature16
Forum Newbie
Posts: 3
Joined: Wed May 17, 2006 9:29 pm

Can't put <> in variable?

Post by signature16 »

Code: Select all

$email2 = "email@domain.com <FirstName LastName>";

I am trying to get this variable to have the email and name contents as show above.. but when i echo the variable out the stuff inside the side brackets is screwed up.

How can I get that into a variable?
kurbot
Forum Newbie
Posts: 18
Joined: Tue Jul 20, 2010 2:20 pm

Re: Can't put <> in variable?

Post by kurbot »

try:

Code: Select all

$email2 = 'email@domain.com <FirstName LastName>';
echo htmlentities($email2);
if your just trying to display it visually
whizzopia
Forum Newbie
Posts: 8
Joined: Sun Sep 02, 2007 6:17 pm

Re: Can't put <> in variable?

Post by whizzopia »

'Less than' and 'greater than' sign are used to identify html tags.
If you see the html source in the browser, you will see that <> is actually there.
So, you have to convert < to &lt and > to &gt.
You can use htmlentities() function to convert them.
signature16
Forum Newbie
Posts: 3
Joined: Wed May 17, 2006 9:29 pm

Re: Can't put <> in variable?

Post by signature16 »

I am not trying to print that out. I'm trying to make a link to be used in curl which needs that formating I believe.
kurbot
Forum Newbie
Posts: 18
Joined: Tue Jul 20, 2010 2:20 pm

Re: Can't put <> in variable?

Post by kurbot »

if your passing the variable to Curl, then what you have already is fine.. if your trying to echo it to the screen then reference the htmlentities
Post Reply