Code – PHP OOP Lazyfuck Class

Just testing this syntax highlighting, this is an object oriented class with setter, getter, and method to make a random age. You could make all kinds of things with this example. I made it when I was practicing OOP coding.

<?php

// PHP OOP
// LazyFuck Class by Ryan B.
// Testing code I made awhile back.

class Lazyfuck {
  private $name;
  private $age;
  public function __construct() {
    echo 'New <strong>'.__CLASS__.' </strong>object created<br>';
   }
   public function __set($property, $value) {
     if (property_exists($this, $property)) {
       $this->$property = $value;
     }
   }
   public function __get($property) {
   if (property_exists($this, $property)) {
      return $this->$property; 
     }
   }
   public function oldAge() {
       return $this->age + rand(1, 50);
   }
}
$lf1 = new Lazyfuck();
$lf1->name = 'Dood';
$lf1->age = '25';
echo $lf1->name. '<br>';
//echo $lf1->age;
echo $lf1->oldAge();

?>

Leave a Comment