karlakmkj

static members

Sep 21st, 2021
806
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2. class AdamsUtils {
  3.   public static $the_answer = 42;
  4.   public static function addTowel($string) {
  5.     return $string . " and a towel.";
  6.   }
  7. }
  8.  
  9. $items = "I brought apples";
  10. echo AdamsUtils::$the_answer;  // use Scope Resolution Operator (::) to access static members
  11. echo "\n";
  12. echo AdamsUtils::addTowel($items);
RAW Paste Data