我的PHP应用程序出现了这个错误
(syntax error, unexpected 'public' (T_PUBLIC), expecting variable (T_VARIABLE) ln6)
我还没有找到解决方案
class User
{
public const STATUS_ACTIVE = 'active';
public const STATUS_INACTIVE = 'inactive';
public function __construct(public string $username, public string $status = self::STATUS_ACTIVE)
{
}
}
参数中不应该有public、private或protected这样的访问修饰符。因为任何函数的形参都是输入,所以设置public、private或protected没有任何意义。
<?php
class User
{
public const STATUS_ACTIVE = 'active';
public const STATUS_INACTIVE = 'inactive';
public function __construct( string $username, string $status = self::STATUS_ACTIVE)
{
}
}