I do not understand I have this message appear (php8).
Thank you
Deprecated: Required parameter $to_addr follows optional parameter $to_name in /home/www/admin/OM/Mail.php on line 237 Deprecated: Required parameter $to_email_address follows optional parameter $to_name in /home/www/admin/OM/Mail.php on line 363 public function send(string $to_name = '', string $to_addr, string $from_name, string $from_addr, string $subject = '', bool $reply_to = false): bool
Advertisement
Answer
In PHP 8, named parameters were added. This means that from now, parameters without a default value, are required to be BEFORE optional parameters.
An optional parameter is one with a default value: function example(string $optional = '');
. We call them optional, well, because they are optional, as you can call the function as follows: example();
.
Therefore, your prototype should change from:
public function send(string $to_name = '', string $to_addr, string $from_name, string $from_addr, string $subject = '', bool $reply_to = false): bool
to
public function send(string $to_addr, string $from_name, string $from_addr, string $to_name = '', string $subject = '', bool $reply_to = false): bool
You can read more about it here: https://www.php.net/manual/en/functions.arguments.php