3v4l.org

run code in 300+ PHP versions simultaneously
<?php /** * Class MailerBootstrap */ class MailerBootstrap { /** * @var string * Hostname */ private $smtp; /** * @var int * TCP Port for SMTP */ private $port; /** * @var string * SMTP Username */ private $username; /** * @var string * SMTP Password */ private $password; /** * MailerBootstrap constructor. * @param string $smtp * @param int $port * @param string $username * @param string $password * Collects SMTP Info */ public function __construct(string $smtp, int $port, string $username, string $password) { $this->smtp = $smtp; $this->port = $port; $this->username = $username; $this->password = $password; } /** * @return Swift_SmtpTransport * Initializes Swift_SmtpTransport Class */ private function buildTransport(): Swift_SmtpTransport { return (new Swift_SmtpTransport($this->smtp, $this->port)) ->setUsername($this->username) ->setPassword($this->password); } /** * @return Swift_Mailer * Initializes Swift_Mailer Class */ private function buildMailer(): Swift_Mailer { return new Swift_Mailer($this->buildTransport()); } /** * @param string $subject * @param array $from * @param array $to * @param string $body * @return Swift_Message * Builds the Message */ private function buildMessage(?string $subject = null, ?array $from = null, ?array $to = null, ?string $body = null): Swift_Message { return (new Swift_Message($subject)) ->setFrom($from) ->setTo($to) ->setBody($body); } /** * Sends the Message */ public function send(): void { $this->buildMailer()->send($this->buildMessage()); } }
Output for 7.1.0 - 7.1.23, 7.2.0 - 7.2.33, 7.3.16 - 7.3.33, 7.4.0 - 7.4.33, 8.0.0 - 8.0.30, 8.1.0 - 8.1.28, 8.2.0 - 8.2.18, 8.3.0 - 8.3.4, 8.3.6
Output for 8.3.5
Warning: PHP Startup: Unable to load dynamic library 'sodium.so' (tried: /usr/lib/php/8.3.5/modules/sodium.so (libsodium.so.23: cannot open shared object file: No such file or directory), /usr/lib/php/8.3.5/modules/sodium.so.so (/usr/lib/php/8.3.5/modules/sodium.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0
Output for 5.6.38
Parse error: syntax error, unexpected ':', expecting ';' or '{' in /in/NR6qX on line 54
Process exited with code 255.

preferences:
176.64 ms | 401 KiB | 173 Q