'syntax error, unexpected '​' (T_STRING), expecting function (T_FUNCTION) or const (T_CONST) Laravel

I have a shop model you can see it

<?php

namespace App;

use Illuminate\Database\Eloquent\Model;
use TCG\Voyager\Traits\Spatial;


class Shop extends Model
{
    use Spatial;

​   protected $spatial = ['lat'];
}

but it consistently giving me error after writing these lines of code

syntax error, unexpected '​' (T_STRING), expecting function (T_FUNCTION) or const (T_CONST)



Solution 1:[1]

You have a ZERO WIDTH SPACE (U+200B) character at the start of the protected $spatial = ['lat']; line. You can copy the code (from the question) and run it through a tool that revelas non-printable characters (for example https://www.soscisurvey.de/tools/view-chars.php) to see it.

To prevent bugs like this in the future, you may want to configure your editor to display non-printable characters, however not all editors have this feature.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Xeos