Devenet Devenet

Liens en vrac

Quelques 337 marque-pages glanés pendant ma navigation sur le Web.

9 résultats pour #php×

RSS ATOM

Sending a multi-part e-mail with html and plain text

http://bookmarks.ecyseo.net/?rZSKHA

//specify the email address you are sending to, and the email subject
$email = 'email@example.com';
$subject = 'Email Subject';

//create a boundary for the email. This
$boundary = uniqid('np');

//headers - specify your from email address and name here
//and specify the boundary for the email
$headers = "MIME-Version: 1.0\r\n";
$headers .= "From: Your Name \r\n";
$headers .= "To: ".$email."\r\n";
$headers .= "Content-Type: multipart/alternative;boundary=" . $boundary . "\r\n";

//here is the content body
$message = "This is a MIME encoded message.";
$message .= "\r\n\r\n--" . $boundary . "\r\n";
$message .= "Content-type: text/plain;charset=utf-8\r\n\r\n";

//Plain text body
$message .= "Hello,\nThis is a text email, the text/plain version.
\n\nRegards,\nYour Name";
$message .= "\r\n\r\n--" . $boundary . "\r\n";
$message .= "Content-type: text/html;charset=utf-8\r\n\r\n";

//Html body
$message .= "
Hello,
This is a text email, the html version.

Regards,
Your Name";
$message .= "\r\n\r\n--" . $boundary . "--";

//invoke the PHP mail function
mail('', $subject, $message, $headers);

PHP: gethostbynamel

https://www.php.net/manual/en/function.gethostbynamel.php

Récupération de la liste d’adresses IP v4 à partir d’un nom de domaine.

Voir aussi :
• gethostbyname() - Get the IPv4 address corresponding to a given Internet host name
• gethostbyaddr() - Get the Internet host name corresponding to a given IP address
• checkdnsrr() - Check DNS records corresponding to a given Internet host name or IP address
• getmxrr() - Get MX records corresponding to a given Internet host name

Apache tips

http://www.ducea.com/2006/06/16/apache-tips-tricks-hide-php-version-x-powered-by/

Cacher la version de PHP dans les entêtes envoyés par Apache.

Dans le fichier php.ini :
expose_php = off

Extremely light templating system in PHP

https://stackoverflow.com/questions/4065418/php-extremely-light-templating-system

/**
* Renders a single line. Looks for {{ var }}
*
* @param string $string
* @param array $parameters
*
* @return string
*/
function renderString($string, array $parameters)
{
   $replacer = function ($match) use ($parameters)
   {
       return isset($parameters[$match[1]]) ? $parameters[$match[1]] : $match[0];
   };

   return preg_replace_callback('/{{\s*(.+?)\s*}}/', $replacer, $string);
}