vitozy

PHP 8 Named args (spread)

Feb 28th, 2021
841
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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. }
RAW Paste Data

Adblocker detected! Please consider disabling it...

We've detected AdBlock Plus or some other adblocking software preventing Pastebin.com from fully loading.

We don't have any obnoxious sound, or popup ads, we actively block these annoying types of ads!

Please add Pastebin.com to your ad blocker whitelist or disable your adblocking software.

×