Best way to access Class property inside a Static method with PHP

You need the $ sign in front of the variable/property name, so it becomes:

self::$my_paths['imagemagick']

And my_paths is not declared as static. So you need it to be

private static $my_paths = array(...);

When it does not have the static keyword in front of it, it expects to be instantiated in an object.


you cannot access non-static properties in static methods, you either should create an instance of the object in the method or declare the property as static.

Tags:

Php

Oop