Mayflower entdeckt Yii
9. Mai 2012
public function getHours() { $from = explode(':', $this->from); $to = explode(':', $this->to); $fromTime = mktime($from[0], $from[1]); $toTime = mktime($to[0], $to[1]); $diff = abs($toTime - $fromTime) - $this->pause * 60; $hours = $diff / 3600; $hours = round($hours * 2); return $hours / 2; }
function isUTF8($str) { return preg_match('/^([\x09\x0A\x0D\x20-\x7E]|[\xC2][\xA0-\xBF]|[\xC3-\xDF][\x80-\xBF]|\xE0[\xA0-\xBF][\x80-\xBF]|[\xE1-\xEC\xEE\xEF][\x80-\xBF]{2}|\xED[\x80-\x9F][\x80-\xBF]|\xF0[\x90-\xBF][\x80-\xBF]{2}|[\xF1-\xF3][\x80-\xBF]{3}|\xF4[\x80-\x8F][\x80-\xBF]{2})*$/', $str); }
Die Diskussionen zu Pro und Contras sogenannter Template Engines in PHP scheinen kein Ende zu nehmen. Hier eine kleine Sammlung, die fortgeführt werden könnte.
Links zu Template Engines:
statt
require_once 'lib/swift_required.php';
schreibe
spl_autoload_unregister(array('YiiBase','autoload')); Yii::import('application.vendor.swift.swift_required', true); spl_autoload_register(array('YiiBase','autoload'));
function sendHtmlMail($from, $to, $subject, $body, $attachments = array()) { require_once 'lib/swift_required.php'; $message = Swift_Message::newInstance() ->setSubject($subject) ->setFrom($from) ->setTo($to) ->setBody($body, 'text/html'); $transport = Swift_SmtpTransport::newInstance('host', 25) ->setUsername('username') ->setPassword('password'); $mailer = Swift_Mailer::newInstance($transport); return $mailer->send($message); } var_dump(sendHtmlMail("fromMailAddress", "toMailAddress", "subject", "body"));
Letzte Kommentare