Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

feralheart's avatar

Blade Syntax Error with empty string variable

Hi all! I have this input:

<input class="form-control" type="text" id="nameEng" name="nameEng" value="{{$tagTrans['en']}}" />

And if the variable is empty I got this message:

Parse error: syntax error, unexpected ''); ?>">' (T_CONSTANT_ENCAPSED_STRING), expecting ',' or ')'

If it isn't empty everything is perfect. Why?

0 likes
6 replies
AddWebContribution's avatar

you should try this:


<input class="form-control" type="text" id="nameEng" name="nameEng" value="{{!empty($tagTrans['en']) ? $tagTrans['en'] : ' ' }}" />



tisuchi's avatar

Then try this-

value="{{ !empty($tagTrans['en'])? $tagTrans['en'] : '' }}"

I believe, its not for that, its for something else where you use unexpected ); ?>.

You better show your controller method code and view code where did you use custom php.

1 like
feralheart's avatar

@saurabh I tried it but it's the same

@tisuchi I use Laravel 5.5 and it shows this row as the error. My action looks like this:

public function newTag($id = 0){

        $tag = array();
        $tagTrans = array();

        if ($id > 0){
            $tag = Tags::where(['id' => $id])
                            -> first()
                            -> toArray();

            $tagTransRaw = TagTrans::where(
                                    ['tag_id' => $id ])
                                ->get()
                                ->toArray();

            foreach ($tagTransRaw as $key => $tagTransFE) {
                $tagTrans[$tagTransFE['lang']] = $tagTransFE['text'];
            }  
        }

        $data = array(
                'id' => $id,
                'tag' => $tag,
                'tagTrans' => $tagTrans,
            );

        return view('back/news/newTag', $data);
    }
tisuchi's avatar

It seems not for this. Can you show me full of your controller code and view code as well?

1 like
AddWebContribution's avatar

Please give output as per below code:

 print('<pre style="color:red;">');
 print_r($data);
 print('</pre>');
 exit;



feralheart's avatar

@saurabh @tisuchi I deleted the value="..."-s in the form to show the var_dump($data),, and now it shows the same error on the end of the file (when it renders the blade templates).

I now thinking about that it's a composer update error what I ran a few hours ago. I checked in git that the updated packages was these:

package name
version from
version to

"name": "laravel/framework", 
"version": "v5.5.19", 
"version": "v5.5.20", 

"name": "nikic/php-parser", 
"version": "v3.1.1", 
"version": "v3.1.2",

"name": "psy/psysh", 
"version": "v0.8.13", 
"version": "v0.8.14", 

"name": "doctrine/instantiator", 
"version": "1.0.5", 
"version": "1.1.0", 

"name": "phpunit/php-code-coverage", 
"version": "5.2.2", 
"version": "5.2.3",

"name": "phpunit/phpunit", 
"version": "6.4.3", 
"version": "6.4.4", 

"name": "sebastian/comparator", 
"version": "2.0.2", 
"version": "2.1.0", 

Please or to participate in this conversation.