Phpmailer: Parse error: syntax error, unexpected 'use' (T_USE)

Created on 3 Sep 2017  路  1Comment  路  Source: PHPMailer/PHPMailer

Problem description

I've always sent from PHPMailer with ease, it always works well. However, after updating to the newer version, I ran composer install within the PHPMailer directory and then ran composer require phpmailer/phpmailer within the directory my functions file is at, which sends the email. Hoping this would work well. However, when I used the example to try and send a test email, an error arose: Parse error: syntax error, unexpected 'use' (T_USE) I don't understand what went wrong.

Code to reproduce

use PHPMailerPHPMailerPHPMailer;
use PHPMailerPHPMailerException;

I then required once the autoload file which loaded fine.

Any ideas?

Most helpful comment

Nevermind, it was inside a function instead of at the top of the PHP file.

>All comments

Nevermind, it was inside a function instead of at the top of the PHP file.

Was this page helpful?
0 / 5 - 0 ratings