The best way to give a variable a default value in PHP is to use the ternary operator ?:.
collections.defaultdict is a subclass of the built-in dict class in Python.