Search code examples
phplaravelhref

I am unable to link href tag inside php


I am trying to redirect the users based on the roles but I can not add an href tag inside the PHP tag for some reason.

<div class="container">
    <div class="row justify-content-center">
        <div class="col-md-8">
            <div class="card">
                <div class="card-header">Dashboard</div>


                <?php if(auth()->user()->isAdmin == 1){?>
                  <div class="panel-body">
                  <a href="{{url('admin/routes')}}"> Welcome to the Admin panel!</a>
                </div><?php } else echo "<div class='panel-heading'> <a href='{{url(route('blog'))}}'>Normal User</a></div>";?>

            </div>
        </div>
    </div>
</div>

Solution

  • You can try these methods to create html link in php

    <?php
        echo "<a href='https://www.google.com' target='_blank'>Text</a>";
    
        $link = "<a href='https://www.quora.com' target='_blank'>Text</a>";
        ?>
    

    Or you can try this markup too

    "<td><a href='http://yourlink'>delete</a></td>";