SHARE
TWEET

Untitled

a guest Oct 22nd, 2019 89 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2.     class Trans {
  3.         private $word;
  4.        
  5.         public function __construct(string $word) {
  6.             $this->word = $word;
  7.         }
  8.    
  9.         public function __invoke(array $replaces) {
  10.             return str_replace(array_keys($replaces), array_values($replaces), $this->word);
  11.         }
  12.    
  13.         public function __toString() {
  14.             return $this->word;
  15.         }
  16.     }
  17.  
  18.    
  19.     $a = new Trans('Hello World');
  20.    
  21.     echo $a;
  22.    
  23.     echo $a(['Hello' => 'Buy']);
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top