我刚写了这样的代码:
<?php
class test
{
// Force Extending class to define this method
abstract protected function getValue();
abstract protected function prefixValue($prefix);
// Common method
public function printOut() {
print $this->getValue() . "\n";
}
}
class testabs extends test{
public function getValue()
{
}
public function prefixValue($f)
{
}
}
$obj = new testabs();
?>
Run Code Online (Sandbox Code Playgroud)
当我运行此代码时,我收到以下错误:
致命错误:类测试包含2种抽象方法,因此必须声明为抽象或实现其余的方法(试验::的getValue,测试:: prefixValue)在C:\ wamp64 \第12行WWW \研究\ abstract.php
我理解这个错误的第一部分.我将类测试更改为抽象,错误消失了,但or我无法理解的部分.
我只是尝试从 middileware auth 函数传递用户名
$request->withAttribute('username','XXXXXX');
return $next($request, $response);
Run Code Online (Sandbox Code Playgroud)
但我无法使用此用户名访问
$request->getAttribute('username');
Run Code Online (Sandbox Code Playgroud)
我找到了一个解决方案,它只有在我这样添加时才有效
return $next($request->withAttribute('username','XXXXXX'), $response);
Run Code Online (Sandbox Code Playgroud)
是什么原因?请帮我。我需要传递多个参数 pass。我该怎么办?
我有这样的代码
<?php
$mask = 5;
$mask |= 10;
echo $mask;
?>
Run Code Online (Sandbox Code Playgroud)
上面代码的输出是15。但我无法理解运算符|=