Advertisement
vitozy

PHP 8 Named args (spread)

Feb 28th, 2021
1,277
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.53 KB | None | 0 0
  1. <?php
  2.  
  3. namespace App\Test;
  4.  
  5. class Named {
  6.     public function test() {
  7.         $this->sendMessage(
  8.             subject: "Teszt",
  9.             body: "Szöveg",
  10.             recipient: "toyou@mailer.test"
  11.         );
  12.  
  13.         $message = [
  14.             "subject" => "Teszt",
  15.             "body" => "Szöveg",
  16.             "recipient" => "toyou@mailer.test"
  17.         ];
  18.  
  19.         $this->sendMessage(...$message);
  20.     }
  21.  
  22.     private function sendMessage($subject, $body, $recipient) {
  23.         dump($subject, $body, $recipient);
  24.     }
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement