我遇到了一些我无法解释为什么它不会在PHP中抛出错误的东西.如果这对你们中的某些人来说非常明显,或者之前已经得到过回答,那就道歉了.
这不会引起任何问题,它只是一种观察和对理解的追求.我想知道是否有人知道为什么会发生这种情况?我只是好奇,因为它似乎根本不应该工作.我错过了什么?
PHP版本测试:PHP v7.2.12
<?php
class FooBar
{
public function foo()
{
anythingIWantToWrite: // this doesn't throw an error?
return "foo";
}
public function baz()
{
baz: 'foobar'; // this doesn't throw an error?
return "bar";
}
}
$class = new FooBar();
echo $class->foo()."\n";
echo $class->baz();
Run Code Online (Sandbox Code Playgroud)