I came across something that I can't explain why it doesn't throw an error in PHP. Apologies if this is glaringly obvious to some of you, or if it has been answered before.
This is not causing any issues, it is more just an observation and a quest for understanding. I am wondering if anyone knows off the top of their head why this happens? I am just curious as it doesn't seem like it should work at all. What am I missing?
PHP version tested: 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();