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 Properties

PHP Last Updated: Oct 17, 2025

Static Properties

Static properties can be accessed directly without creating an instance of a class. Static properties can be declared by using the static keyword.

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

Example:

<?php
class pi {
 public static $value = 3.14;
}
// Getting static property
echo pi::$value;
?>

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 pi {
 public static $value = 3.14159;
 public function staticValue() {
   return self::$value;
 }
}

$pi = new pi();
echo $pi->staticValue();
?>

If we need to call a static property from a child class, we can use the parent keyword inside the child class.

Example:

<?php
class pi {
 public static $value = 3.14;
}
class x extends pi {
 public function xStatic() {
   return parent::$value;
 }
}
// Get value of static property directly via child class
echo x::$value;
?>

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 →