html link

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
kebo
Forum Newbie
Posts: 9
Joined: Mon Aug 28, 2006 9:16 am

html link

Post by kebo »

new to php here.....please excuse the...well lack of knowledge of the obvious....


how would I insert a link such as

Code: Select all

echo <a href="www.google.com"> www.google.com</a>
into php code?
thanks
kevin
olegkikin
Forum Newbie
Posts: 12
Joined: Wed Jun 21, 2006 10:01 pm

Post by olegkikin »

At least two ways:

1)

Code: Select all

echo "<a href=\"http://www.google.com\">www.google.com</a>";
2)

Code: Select all

?>
<a href="http://www.google.com">www.google.com</a>
<?
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Post by RobertGonzalez »

My favorite...

Code: Select all

echo '<a href="htp://www.google.com">www.google.com</a>';
Then you don't have to escape your quotes.
kebo
Forum Newbie
Posts: 9
Joined: Mon Aug 28, 2006 9:16 am

Post by kebo »

excellent...thanks for the quick reply.....
kevin
jabbaonthedais
Forum Contributor
Posts: 127
Joined: Wed Aug 18, 2004 12:08 pm

Post by jabbaonthedais »

Everah wrote:My favorite...

Code: Select all

echo '<a href="htp://www.google.com">www.google.com</a>';
Then you don't have to escape your quotes.
Cool, I didn't know you could do that! I normally do it with single quotes in the html. I guess thats dangerous for browser compatability though.

Code: Select all

echo "<a href='htp://www.google.com'>www.google.com</a>";
kebo
Forum Newbie
Posts: 9
Joined: Mon Aug 28, 2006 9:16 am

Post by kebo »

so....lets see if I understand....

If I want to output html is php, I use echo and <....>....</> ?

what do I do if I want to output a "<" such as if I am creating an xml doc ?

for example, i want to ouptut somthing like

<Name> MyName </Name> ?

thanks
kevin
Post Reply