# Blade file not fully converting to PHP

**URL:** https://discourse.roots.io/t/blade-file-not-fully-converting-to-php/15767
**Category:** sage
**Created:** 2019-06-05T16:44:24Z
**Posts:** 5

## Post 1 by @JordanC26 — 2019-06-05T16:44:24Z

Got a fatal error whilst developing a new page template, looked at the cached php file which sage is using and I see only half the file converts to \<?php from @php

`Fatal error: Uncaught Symfony\Component\Debug\Exception\FatalThrowableError: syntax error, unexpected '@' in /tmp/sage-cache/bd612976b245b29432910d0149089850b49fcd08.php on line *46*`

 ![17](https://discourse.roots.io/uploads/default/original/2X/a/af5a393f9754e736072ccb80fb2a17cd430d180d.png)

The error starts at `@else` middle of the file…

Running PHP 7, no similar issues recently.

---

## Post 2 by @codepuncher — 2019-06-05T17:35:43Z

Hi @JordanC26, can you share your blade template with us? Without it, it’s hard to see what’s caused it.

Looking at the cache file, though, it looks like you are using the shorthand php directive `@php()`. If so, don’t use the shorthand.

---

## Post 3 by @JordanC26 — 2019-06-06T09:15:45Z

Hi @codepuncher, that was it, thank you!

Still had this old shorthand php leftover, now updated.

```
{{-- Create active class if this is the first item in the loop --}}
@if ( $loop->first )
  @php( $active_status = 'active' )
@else
  @php( $active_status = '' )
@endif
```

**Updated**

```
{{-- Create active class if this is the first item in the loop --}}
@if ( $loop->first )
  @php
    $active_status = 'active';
  @endphp
@else
  @php
    $active_status = '';
  @endphp
@endif
```

---

## Post 4 by @alwaysblank — 2019-06-06T17:02:49Z

You could also do this in a single line with ternary operators:

```
@php $active_status = $loop->first ? 'active' : '' @endphp
```

---

## Post 5 by @PrecisionCoder13 — 2019-06-10T04:33:58Z

You don’t need to start & end PHP inside your @if / @else.

---

## Post 6 by @system — 2019-07-17T16:44:26Z

This topic was automatically closed after 42 days. New replies are no longer allowed.
