Problemi con l'utilizzo di PHP Swift Mailer
-
28-10-2019 - |
Domanda
Cosa ho fatto:
- ) Swift-4.1.5.tar scaricato
- ) Estratto
- ) Caricato sul mio host in / public_html / domain / lib utilizzando FileZilla
- ) Crea un nuovo script utilizzando il codice seguente.
- ) L'ho aperto nel browser e ho ricevuto il seguente errore di seguito
Quindi la mia domanda è: come ricevo l'errore che il file non esiste se è al 100%?Grazie!
<?php
require_once '/public_html/domain/lib/swift_required.php';
?>
Avviso: require_once (/public_html/domain/lib/swift_required.php) [function.require-once]: impossibile aprire lo stream: nessun file o directory di questo tipo in /home/myuser/public_html/domain/email.php suriga 5
Errore irreversibile: require_once () [function.require]: apertura non riuscita richiesta '/public_html/domain/lib/swift_required.php' (include_path= '.: / usr / lib / php: / usr / local / lib /php ') in /home/myuser/public_html/domain/email.php sulla riga 5
Ecco uno screenshot della mia directory da FileZilla. http://i.imgur.com/Zsy8y.jpg
Soluzione
Questo è sbagliato:
// this is absolute path, just like /home/user or /var/www
require_once '/public_html/domain/lib/swift_required.php';
Utilizza invece:
// this is relative path to the current file
require_once 'public_html/domain/lib/swift_required.php'; //notice: no '/' in the beggining
OPPURE:
// so use this one if you know the whole path to the file
require_once ABSOLUTE_PATH_TO . 'public_html/domain/lib/swift_required.php';
OPPURE:
// or use this one if you don't know the whole path
// or if the path will change (dev machine and production machine)
require_once dirname(__FILE__) . RELATIVE_PATH_TO . 'public_html/domain/lib/swift_required.php';