I'm trying to fix some code I got from a friend. It features a lot of if(!$var) lines and it results in a false positive. When I change it to isset($var) the code runs through. This is fine in some places, but it's not exactly the same.
I have read change documentation for PHP 5.1 and further on this topic. I believe this code is from an older version of PHP, but I cannot find where handling of this code has changed.
Is the code outdated, or am I missing something like a PHP extension?
examples of code with problem:
function mailTo($to, $subject, $body, $meta, $from, $from_friendly){
$mail = new PHPMailer;
$mail->isSMTP();
$mail->SMTPDebug = 0;
$mail->Debugoutput = 'html';
$mail->Host = $meta['smtp_server'];
if(isset($meta['smtp_port']))
$mail->Port = $meta['smtp_port'];
$mail->SMTPAuth = true;
$mail->Username = $meta['smip_uname'];
$mail->Password = $meta['smip_pwd'];
$mail->setFrom($from, $from_friendly);
$mail->addReplyTo($from, $from_friendly);
$mail->addAddress($to);
$mail->Subject =$subject;
$mail->msgHTML($body);
$mail->AltBody = strip_tags($body);
if (!$mail->send()) {
return false;
} else {
return true;
}
}
example 2:
public function getMessage($conn, $messageId) {
$structure = imap_fetchstructure($conn, $messageId);
// If message is not multipart
if (!$structure->parts) {
$this->getMessagePart($conn, $messageId, $structure, 0);
}
else {
foreach ($structure->parts as $partno => $part) {
$this->getMessagePart($conn, $messageId, $part, $partno+1);
}
}
}
Aucun commentaire:
Enregistrer un commentaire