Wednesday, September 18, 2019

Parse error Unexpected (, expected , in php when assign content file to a static property

It's because you have assigned expression to variable declaration. It can only use constants.


The workaround would be like this


class MyClass {
...
public static $MyString;
...
}
MyClass::$MyString = file_get_contents('file.txt');

No comments:

Post a Comment

hard drive - Leaving bad sectors in unformatted partition?

Laptop was acting really weird, and copy and seek times were really slow, so I decided to scan the hard drive surface. I have a couple hundr...