Programming: May 2014 Archives

PHP RePOST data

user-pic
Vote 0 Votes

Recieve POST and RePOST data to somewhere. Similar to POST redirection.

$ch = curl_init('http://yourhost.com/post.php');
$postdata = file_get_contents("php://input");
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $postdata);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$response = curl_exec($ch);

PHP mb_send_mail

user-pic
Vote 0 Votes

PHP mb_send_mail
Subject and message are automatically encoded,
to and additional_headers are not automatically encoded.

mb_send_mail 比 mail 好用很多, 主旨及本文會自動依 mbstring.internal_encoding 處理編碼
但是當 to and additional_headers 有包含 multi-byte 時, multi-byte 部份要用 mb_encode_mimeheader 處理過才會正常
e.g.
$to=mb_encode_mimeheader("王大頭")." <foo@test.com>";
$additional_headers="From: ".mb_encode_mimeheader("王小頭")." <bar@test.com>\nContent-Type: text/plain; charset=UTF-8";
mb_send_mail($to,$subject,$message,$additional_headers);

About this Archive

This page is an archive of entries in the Programming category from May 2014.

Programming: March 2013 is the previous archive.

Programming: July 2014 is the next archive.

Find recent content on the main index or look in the archives to find all content.

Monthly Archives