Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html>
- <html>
- <head>
- <meta charset="utf-8">
- <title>static</title>
- <link rel="stylesheet" href="/css/master.css">
- <style media="screen">
- *{margin: 0;padding: 0;}
- body{background-color: gray;}
- .header
- {
- width: 960px;
- height: 50px;
- background: green;
- margin: 20px auto;
- border: 2px solid white;
- border-radius: 10px;
- }
- .header h2
- {
- color: white;
- margin-left: 200px;
- padding: 8px;
- font-family: arial;
- }
- .main
- {
- width: 960px;
- height: 450px;
- background: green;
- margin: 10px auto;
- border: 1px solid white;
- border-radius: 20px;
- }
- .main .code
- {
- margin: 10px 20px;
- color: white;
- font-weight: bold;
- font-size: 20px;
- font-family: verdana;
- }
- .footer
- {
- width: 960px;
- height: 50px;
- background: green;
- margin: 10px auto;
- border: 2px solid white;
- border-radius: 10px;
- }
- .footer h2
- {
- color: white;
- margin-left: 250px;
- padding: 8px;
- font-family: arial;
- }
- </style>
- </head>
- <body>
- <div class="header">
- <h2>How to define static variable in php:</h2>
- </div>
- <div class="main">
- <div class="code">
- <p>static:</p>
- <br>
- <?php
- class student
- {
- public static $studentAge = "21";
- public static function studentData()
- {
- echo "Age: ".self::$studentAge."<br>"; //static variable is accessed;
- }
- }
- $studentInfo = new student;
- $studentInfo::studentData();
- echo "<br>";
- ?>
- </div>
- </div>
- <div class="footer">
- <h2>© the hompage is created by <i>Riju</i></h2>
- </div>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment