PHP Error: Expected T_PAAMAYIM_NEKUDOTAYIM — What Does It Mean?
Hi everyone! I'm a beginner in PHP and trying to understand classes. I'm writing a simple script, but I get an error: "Parse error: syntax error, unexpected '::' (T_PAAMAYIM_NEKUDOTAYIM)".
Here's my code:
```php
class User {
public $name = "Guest";
public function greet() {
return "Hello, " . $this->name;
}
}
$user = new User();
echo $user->greet();
// But here I want to call the method without creating an object
echo User::greet();
```
I thought that using `::` you can call class methods, like in other languages. But the interpreter complains. What am I doing wrong? Why doesn't PHP understand this syntax? And what does this strange word "T_PAAMAYIM_NEKUDOTAYIM" even mean?
I googled it, but there's little information in Russian. Please help me figure it out. Maybe I declared the method incorrectly or need to write something special? Thanks in advance!
<<>>
What is T_PAAMAYIM_NEKUDOTAYIM?
This is a PHP token that denotes the scope resolution operator
No answers yet.
Log in to leave an answer