TechniqueUse the :: notation, which enables you to access functions in a class without using an object: <?php class Conversion { function feet_to_meters($feet) { return $feet * 0.3054; } } $average_height = Conversion::feet_to_meters(6); ?> CommentsThe :: notation enables you to access function in classes without an object, but how do you access variables from within a class without an object? You don't. At the time this book was written, PHP supports only the capability to access methods ”not variables ”without using an object. However, after you have an object, you can access both variables and functions via that object. |