user550265
user550265

Reputation: 3289

showing hyperlinks using php

Is there a better way to show hyper links in php than using

<a href="<?php echo $link; ?>"><?php echo $link; ?></a>

Upvotes: 0

Views: 748

Answers (3)

Capsule
Capsule

Reputation: 6159

To avoid repeating $link, you can use this:

<?php printf('<a href="%1$s">%1$s</a>', $link); ?>

Upvotes: 3

Ryan Kinal
Ryan Kinal

Reputation: 17732

<?php echo '<a href="'.$link.'">'.$link.'</a>'; ?>

Upvotes: -1

delphist
delphist

Reputation: 4539

<a href="<?=$link?>"><?=$link?></a>

Upvotes: 2

Related Questions