Static Properties in PHP
You can call static properties directly, without making a new instance of a class.
The static keyword is used to declare properties that don\’t change:
Syntax
<?php
class Class_Name {
public static $variable = \”Coderazza.com\”;
}
?>
Use the class name, a double colon (::), and the property name to get to a static property:
Syntax
Class_Name::$variable ;
Example
<!DOCTYPE html>
<html>
<body>
<?php
class rad {
public static $result = 8.9876654321;
}
// Get static property
echo rad::$result;
?>
</body>
</html>
Output
8.9876654321
Related Article
PHP Tutorial
PHP Tutorial – Complete Guide for Beginners to Advanced Welcome to the most comprehensive PHP tutorial available online at PHPOnline.in Read more
Introduction of PHP
Introduction to PHP – Learn PHP from Scratch with Practical Examples Welcome to your complete beginner's guide to PHP. Whether Read more
Syntax Overview of PHP
Syntax Overview of PHP (2025 Edition) Welcome to phponline.in, your one-stop platform for mastering PHP. This comprehensive, SEO-rich tutorial on Read more
Variable Types in PHP
PHP Variable Types: Complete Beginner's Guide to PHP Data Types Welcome to phponline.in, your trusted source for beginner-to-advanced level PHP Read more