Skip to content


DevShed: PHP 5 Helpers: Calling Methods Out of Object Scope

In this new tutorial from DevShed today they continue their series looking at making helper classes for your applications. This time they’re focusing on using methods without needing to create an object first – static methods.

The methods of the class that I [just] mentioned were declared implicitly dynamic, even though it’s perfectly possible to call them statically, and the PHP engine won’t raise any errors about this process. However, it would be much better to declare these methods explicitly static, thus taking advantage of the functionality offered by the text helper class without having to spawn an instance of it.

They show how to define the methods with the “static” keyword so they can be called outside of the class’ scope. Code for the helper class and the code to put it to use.

Posted in PHP.


0 Responses

Stay in touch with the conversation, subscribe to the RSS feed for comments on this post.



Some HTML is OK

or, reply to this post via trackback.



close