不允许" - "控制器文件中的字符

时间:2015-05-13 11:38:50

标签: laravel laravel-5

我通过作曲家包下载了有字符" - "在名字里。然后当我尝试使用它时出现错误

  use Marekweb\Opaque-id\OpaqueEncode;

错误:

  syntax error, unexpected '-', expecting ',' or ';'

2 个答案:

答案 0 :(得分:2)

我不知道你是如何使用这个命名空间的,但是OpaqueEncoder类只是doesn't have one(因此驻留在根命名空间中),你只需编写use OpaqueEncoder来导入它非根名称空间。

更新。 根本没有任何名称空间

namespace Xyz\Anything;

use OpaqueEncoder;

class ABC
{
    public function dunno($key)
    {
        $encoder = new OpaqueEncoder($key);
    }
}

答案 1 :(得分:0)

I don't know the syntax, but the following guesses might help:
  - the backward slashes, should they be forward slashes?
  - maybe a missing semi-colon on the previous line.
  - the '-' might not be the right '-' but rather some other dash.
    you could try deleting and retyping it.
  - character encoding mismatch, utf-8 vs Cp???? (or whatever)
  - character encoding not declared at top of document or in whatever 
    meta placeholder or pragma the language provides.
  - check the actual encoding of your document.
You might get lucky. :)