Riju18

no.51_php_static

Jul 15th, 2017
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.00 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html>
  3.   <head>
  4.     <meta charset="utf-8">
  5.     <title>static</title>
  6.     <link rel="stylesheet" href="/css/master.css">
  7.     <style media="screen">
  8.       *{margin: 0;padding: 0;}
  9.        body{background-color: gray;}
  10.       .header
  11.       {
  12.         width: 960px;
  13.         height: 50px;
  14.         background: green;
  15.         margin: 20px auto;
  16.         border: 2px solid white;
  17.         border-radius: 10px;
  18.       }
  19.       .header h2
  20.       {
  21.         color: white;
  22.         margin-left: 200px;
  23.         padding: 8px;
  24.         font-family: arial;
  25.       }
  26.       .main
  27.       {
  28.         width: 960px;
  29.         height: 450px;
  30.         background: green;
  31.         margin: 10px auto;
  32.         border: 1px solid white;
  33.         border-radius: 20px;
  34.       }
  35.       .main .code
  36.       {
  37.         margin: 10px 20px;
  38.         color: white;
  39.         font-weight: bold;
  40.         font-size: 20px;
  41.         font-family: verdana;
  42.       }
  43.       .footer
  44.       {
  45.         width: 960px;
  46.         height: 50px;
  47.         background: green;
  48.         margin: 10px auto;
  49.         border: 2px solid white;
  50.         border-radius: 10px;
  51.       }
  52.       .footer h2
  53.       {
  54.         color: white;
  55.         margin-left: 250px;
  56.         padding: 8px;
  57.         font-family: arial;
  58.       }
  59.     </style>
  60.   </head>
  61.   <body>
  62.     <div class="header">
  63.       <h2>How to define static variable in php:</h2>
  64.     </div>
  65.     <div class="main">
  66.       <div class="code">
  67.         <p>static:</p>
  68.         <br>
  69.         <?php
  70.           class student
  71.           {
  72.             public static $studentAge = "21";
  73.             public static function studentData()
  74.             {
  75.               echo "Age: ".self::$studentAge."<br>"; //static variable is accessed;
  76.             }
  77.           }
  78.           $studentInfo = new student;
  79.           $studentInfo::studentData();
  80.           echo "<br>";
  81.          ?>
  82.       </div>
  83.     </div>
  84.     <div class="footer">
  85.       <h2>&copy; the hompage is created by <i>Riju</i></h2>
  86.     </div>
  87.   </body>
  88. </html>
Advertisement
Add Comment
Please, Sign In to add comment