Learn How To Add A Tag With Href Link In PHP With Html

admin_img Posted By Bajarangi soft , Posted On 15-09-2020

Links are search  for web pages. Links allow users to click their way from  one web page to another web page. Links can also jump to another document.

Add an href link in PHP

 Let's learn
1.Create php file and execute below codes:

Example(1)

<html>
<head>
    <title></title>
</head>
<body>
<a href='<?php echo $link_to_google; ?>' target='_blank'>Click here to visit Google</a><br/>
<a href='<?php echo $link_to_blog; ?>'>Click here to visit blog.bajarangisoft.com</a>
</body>
</html>


Example(2)

<?php
$link_to_google = "https://google.com";
$link_to_blog = "http://blog.bajarangisoft.com/";

echo "<a href='https://www.google.com' target='_blank'>Click here to visit Google</a>";

$link = "<a href='http://blog.bajarangisoft.com/' >Click here to visit blog.bajarangisoft.com</a>";
echo $link;
?>



Complete Code of   href link in PHP :

<!DOCTYPE html>
<html>
<head>
    <title>Add an href link in PHP</title>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css">
</head>
<body>
<div class="container">
    <div class="text-center">
        <h1>Add an href link in PHP</h1>
    </div>
    <br>
    <h2></h2>
    <div class="well">
        <?php
        $link_to_google = "https://google.com";
        $link_to_blog = "http://blog.bajarangisoft.com/";

        echo "<a href='https://www.google.com' target='_blank'>Click here to visit Google</a>";
        echo "<br>";
        $link = "<a href='http://blog.bajarangisoft.com/' >Click here to visit blog.bajarangisoft.com</a>";
        echo $link;
        echo "<br>";
        ?>
        <a href='<?php echo $link_to_google; ?>' target='_blank'>Click here to visit Google</a><br/>
        <a href='<?php echo $link_to_blog; ?>'>Click here to visit blog.bajarangisoft.com</a>
    </div>
    <br>
</div>
</body>
</html>


 

Related Post