mercredi 29 juin 2016

php condition statement not working [duplicate]

This question already has an answer here:

I'm trying to add a condition statement using php, but it's fighting me. Here's my code.

$ext = pathinfo($path, PATHINFO_EXTENSION);
$fiType = substr($ext, 0, 3);
$iconElem = '';
if ($fiType = 'doc') {
    $iconElem = "fa-file-word-o";
} elseif ($fiType = 'txt') {
    $iconElem = "fa-file-text-o";
} elseif ($fiType = 'xls') {
    $iconElem = "fa-file-excel-o";
} elseif ($fiType = 'ppt') {
    $iconElem = "fa-file-powerpoint-o";
} elseif ($fiType = 'pdf') {
    $iconElem = "fa-file-pdf-o";
} else {
    $iconElem = null;
}

Somehow, I keep getting "fa-file-word-o" no matter what type of file I upload. fiType is different with every file type, but my elseif doesn't think so. Help.

Aucun commentaire:

Enregistrer un commentaire