Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- class Trans {
- private $word;
- public function __construct(string $word) {
- $this->word = $word;
- }
- public function __invoke(array $replaces) {
- return str_replace(array_keys($replaces), array_values($replaces), $this->word);
- }
- public function __toString() {
- return $this->word;
- }
- }
- $a = new Trans('Hello World');
- echo $a;
- echo $a(['Hello' => 'Buy']);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement