Urfaaan
Urfaaan

Reputation: 9

My Php blade variable is not working in simple php

My Php blade variable is

{{$user->account_expiry_date}}

My simple php crud code

Dt = date("d-m-Y");

I store value of blade variable value in simple PHP variable.

$ac_expiry='{{$user->account_expiry_date}}';

Now I echo $ac_expiry and same echo working

But when I use in some condition same variable arn't working

If ($dt <=  $ac_expiry) {
    Do something not working
}

Upvotes: 0

Views: 55

Answers (2)

chaitanya swami
chaitanya swami

Reputation: 430

If you want to use using laravel format you have to write like this

@if(true)
  echo "Success";
@endif

Or if you want to use in core php you can write like this

<?php 
if(true){
  echo "success";
}
?>

Upvotes: 3

Bikash
Bikash

Reputation: 1938

If statement should be like

@if (count($records) === 1)
 I have one record!
@elseif (count($records) > 1)
 I have multiple records!
@else
 I don't have any records!
@endif

here is the doc laravel docs here

In your case, statement should be

@if ($dt <= $ac_expiry) { Do something not working }

Upvotes: 1

Related Questions