Thursday, July 30, 2009

How to write PHP code to create a hyperlink that opens in another window?

how would you write full php code to create a html hyperlink to a website that opens in another window such as yahoo.com?

How to write PHP code to create a hyperlink that opens in another window?
If you particularly want to write it in php (perhaps you are generating the link or something):





%26lt;?php


echo "%26lt;a href=\"the-url.com\" target=\"_blank\"%26gt;anchor text%26lt;/a%26gt;";


?%26gt;





But as stated above, you don't need to use php to do this.
Reply:Easy my friend:





Within an HTML context, read outside of php then just put write the link out. If inside PHP use an echo or print statement:





%26lt;? print( '%26lt;a href="http://mylink.com/path/"%26gt;click Moi%26lt;/a%26gt;'); ?%26gt;





mind you echo will be bad for performance when somany users click on that hyper link, so use print if you really have to.





also check out this resource:


http://uk2.php.net/manual/en/function.fr...





the one below is a specific example though,





Good luck





aurevoir
Reply:If you are referring to a link that will open in a completely new window, it would be like this in php:





%26lt;a href=\"http://www.yahoo.com\"%26gt;Yahoo%26lt;/a%26gt;





Now, depending on your php syntax you may need to wrap it with echo "%26lt;a href=\"http://www.yahoo.com\"%26gt;Yahoo%26lt;/a%26gt;"...
Reply:Hi there,





What you need is simply HTML, NOT PHP :)





%26lt;p%26gt;


Visit %26lt;a href="http://www.YAHOO.com" target="_blank"%26gt;Yahoo!%26lt;/a%26gt; today!


%26lt;/p%26gt;





The target="_blank" opens the link "Yahoo" in a new window.








Hope this helps,


Piet

printable cards

No comments:

Post a Comment