Unexpected 'Use' (T_Use) When Trying to Use Composer

PHP class - PHPMailer unexpected 'use' (T_USE)

The problem is your use of the use keyword. From the documentation:

The use keyword must be declared in the outermost scope of a file (the global scope) or inside namespace declarations. This is because the importing is done at compile time and not runtime, so it cannot be block scoped.

As such, your code should be something like this:

<?php
use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\Exception;

session_start();

if (isset($_SESSION['username']) and $_SESSION['username'] != ''){
[...]

Are there any languages that implement generics _well_?

Haskell implements type-constructor parameterisation (generics, or parametric polymorphism) quite well. So does Scala (although it needs a bit of hand-holding sometimes).

Both of these languages have higher-kinded types (a.k.a. abstract type constructors, or type-constructor polymorphism, or higher-order polymorphism).

See here: Generics of a Higher Kind

PHP use keyword is causing 500 server error

Issue fixed, thanks to this https://stackoverflow.com/a/33355711/7926703

I was using 'use' inside a function which is wrong and error-causing.



Related Topics



Leave a reply



Submit