From 50ad6c05dc30ea8117b49b99569376f1fb7e58a4 Mon Sep 17 00:00:00 2001 From: Adam Spragg Date: Tue, 14 Aug 2018 09:37:18 +0100 Subject: Rename $v to $_v Because it's a variable for the function, not for the included script. Also fix up the docstring slightly --- mailTemplate.php | 50 +++++++++++++++++++++++++------------------------- 1 file changed, 25 insertions(+), 25 deletions(-) (limited to 'mailTemplate.php') diff --git a/mailTemplate.php b/mailTemplate.php index 2481f5e..1ba82b7 100644 --- a/mailTemplate.php +++ b/mailTemplate.php @@ -17,63 +17,63 @@ /** * Send an email using a PHP template file. * - * This function causes the PHP engine to parse the PHP file specified by #_filename, which should output an - * [RFC-822](https://tools.ietf.org/html/rfc822) (and its + * This function causes the PHP engine to parse the PHP file specified by #_filename, with the variables passed in the + * variable #_v, which should output an [RFC-822](https://tools.ietf.org/html/rfc822) (and its * [successors](https://en.wikipedia.org/wiki/Email#Message_format)) style message. * The function then extracts the headers from the message, grabs the "To" and "Subject" lines from it, and then passes - * the "To:", "Subject:", message body, and remaining headers, to the php + * the "To:", "Subject:", message body, and remaining headers, to the PHP * [mail()](https://secure.php.net/manual/en/function.mail.php) function. * * As an example, consider template file "thanks.php" * - * To: <> - * Subject: Thank you for your request - * Content-Type: text/plain; charset=utf-8 + * To: <> + * Subject: Thank you for your request + * Content-Type: text/plain; charset=utf-8 * - * Dear , + * Dear , * - * Thankyou for your request, one of our staff will contact you . - * + * Thankyou for your request, one of our staff will contact you . + * * - * Your request is important to us. - * + * Your request is important to us. + * * * Which could then be called with: * - * mailTemplate("thanks.php", [ - * 'email' => "dave@example.com", - * 'name' => "Dave", - * 'when' => "tomorrow", - * 'important' => FALSE, - * ]}; + * mailTemplate("thanks.php", [ + * 'email' => "dave@example.com", + * 'name' => "Dave", + * 'when' => "tomorrow", + * 'important' => FALSE, + * ]}; * * Note that, as of this implementation, #_filename is read using * [include](https://secure.php.net/manual/en/function.include.php), so it uses the file-finding rules defined therein. * * Also, it is worth remembering that PHP eats newlines directly following a PHP close tag. Therefore, if you have: * - * To: - * Subject: ... + * To: + * Subject: ... * * Then the newline following the close tag will be eaten by the PHP parser, and you'll end up with: * - * To: example@example.comSubject: ... + * To: example@example.comSubject: ... * * To work around this, you need to either make the closing tag not the last thing on the line (e.g. by adding a * trailing space to the line), or forcibly output a newline yourself from within the PHP, e.g.: * - * To: - * Subject: ... + * To: + * Subject: ... * * @param string $_filename Filename of PHP template file to send. - * @param mixed $v Associated array of variables to be made available to the mail template. + * @param mixed $_v Associated array of variables to be made available to the mail template. * * @return bool TRUE on success, FALSE on failure. */ -function mailTemplate($_filename, $v) +function mailTemplate($_filename, $_v) { ob_start(); - extract($v, EXTR_OVERWRITE); + extract($_v, EXTR_OVERWRITE); if (!include($_filename)) { /* Don't need to raise a warning here, include will do that for us. */ ob_end_clean(); -- cgit v1.2.1