我有兩件事情我想在這裏做,但我很悲慘失敗,我已經嘗試了一切,所以我不知道原因。PHP str_replace問題
我試圖用
str_replace
刪除版權,但電子郵件的版權簽名出現。出於某種原因,在消息中的隨機點,它正在輸入數字。我真的很困惑爲什麼會這樣。以下是PHP代碼以及HTML輸出的外觀。
****新的輸出:**** 我加入了QPRINT,現在我得到:
輸出:
代碼:
<?php
/* connect to gmail */
$hostname = '{imap.gmail.com:993/imap/ssl}INBOX';
$username = '[email protected]';
$password = 'Password';
/* try to connect */
$inbox = imap_open($hostname, $username, $password) or die('Cannot connect to Gmail: ' . imap_last_error());
/* grab emails */
$emails = imap_search($inbox, 'ALL');
/* if emails are returned, cycle through each... */
if ($emails) {
/* begin output var */
$output = '';
/* put the newest emails on top */
rsort($emails);
/* for every email... */
foreach ($emails as $email_number) {
/* get information specific to this email */
$overview = imap_fetch_overview($inbox, $email_number, 0);
$message = imap_fetchbody($inbox, $email_number, 2);
$DateFormatted = str_replace("-0500", "", $overview[0] -> date);
/* output the email header information */
$output .= '<span class="msg_subject">' . $overview[0] -> subject . '</span> | ';
$output .= '<span class="msg_date"> ' . $DateFormatted . '</span><br />';
$bodyFormatted = str_replace("This e-mail (and attachment(s)) is confidential, proprietary, may be subject to copyright and legal privilege and no related rights are waived. If you are not the intended recipient or its agent, any review, dissemination, distribution or copying of this e-mail or any of its content is strictly prohibited and may be unlawful. All messages may be monitored as permitted by applicable law and regulations and our policies to protect our business. E-mails are not secure and you are deemed to have accepted any risk if you communicate with us by e-mail. If received in error, please notify us immediately and delete the e-mail (and any attachments) from any computer or any storage medium without printing a copy.
Ce courriel (ainsi que ses pièces jointes) est confidentiel, exclusif, et peut faire l’objet de droit d’auteur et de privilège juridique; aucun droit connexe n’est exclu. Si vous n’êtes pas le destinataire visé ou son représentant, toute étude, diffusion, transmission ou copie de ce courriel en tout ou en partie, est strictement interdite et peut être illégale. Tous les messages peuvent être surveillés, selon les lois et règlements applicables et les politiques de protection de notre entreprise. Les courriels ne sont pas sécurisés et vous êtes réputés avoir accepté tous les risques qui y sont liés si vous choisissez de communiquer avec nous par ce moyen. Si vous avez reçu ce message par erreur, veuillez nous en aviser immédiatement et supprimer ce courriel (ainsi que toutes ses pièces jointes) de tout ordinateur ou support de données sans en imprimer une copie.", "", $message);
/* output the email body */
$output .= '<span class="msg_body">' . $bodyFormatted . '</span><br /><br />';
}
echo $output;
}
/* close the connection */
imap_close($inbox);
?>
的「隨機字符串」似乎編碼值。它們不是隨機的,而是編碼版本的'''''''''和其他重音字母。 – Qqwy
它在甚至沒有重音字母的地方添加數字。它需要一定的空間並用這些數字取代它們。 – Bulvak
例如,原始電子郵件:請注意,沃爾德代爾/蒙特利爾數據中心(SDE)將於12月6日/ 7日(沃爾德代爾)和12月12日/ 13日進行網絡維護(蒙特利爾)。在此維護期間,預計不會停機。範圍:由於在受影響的路由器上發現問題,需要緊急網絡維護。影響:媒體基礎架構上的所有託管網站,包括但不限於(可能即將進行的遷移): – Bulvak