I am trying to link my css file via asset like:
@if(session()->has('locale'))
<?php $file_name = "css/".session()->get('locale').'.css'; ?>
<link href="{{asset('<?php echo $file_name;?>')}}" rel="stylesheet">
@endif
the value $file_name
is dr but at source-view is shows like: <link href="{{asset('css/dr.css')}}" rel="stylesheet">
the link address is no correct it must show <link href="http://localhost:8000/css/dr.css" rel="stylesheet">
what should I use instead of asset or url?
the {{ }}
will already transform this to php syntax. If you look at storage/framework/views
there will be some "compiled" files of the view. There is no need to use <?php echo ... ?>
. Just use:
<link href="{{asset($file_name)}}" rel="stylesheet">
Make sure your view filename is something.blade.php