Courses Job Ready Fresher Training AI for Class 7 to 12 Corporate Training Placements Tutorials
Free Learning Resources

IT Tutorials & Interview Prep

Free guides, interview Q&As, and job responsibility breakdowns — curated by industry veterans to help you crack MNC interviews

109+
Tutorial Articles
9
Topic Categories
100%
Free to Read
← Back to PHP

Static Methods

PHP Last Updated: Oct 17, 2025

Static Methods

In certain cases where we need to access methods and properties in terms of class rather than an object, the static methods come for help. Any method declared as static can be accessed without creating an object.

Static methods are declared with the static keyword.

Example

<?php
class ClassName {
 public static function staticMethod() {
   echo "Hello World!";
 }
}
?>

To access a static method we need to use the class name followed by a double colon (::), and the method name.

Example:

<?php
class greeting {
 public static function welcome() {
   echo "Hello Bhai!";
 }
}

// Call static method
greeting::welcome();
?>

A static method can be accessed from a method in the same class using the self keyword followed by a double colon (::), and the method name.

Example:

<?php
class greeting {
 public static function welcome() {
   echo "Hello Bro!";
 }
 public function __construct() {
   self::welcome();
 }
}
new greeting();
?>

Want to practice these scenarios in a real IT environment? Our 45-Day Internship Program gives you hands-on experience with Active Directory, Ticketing Tools, and Networking.
Join the Internship →