??? ?? ??? ??? ??? ?? ??? ?? PHP ?? ?? ??
Jul 29, 2016 am 08:38 AMclass Email {
//---?? ?? ??
var $mailTo = ""; // ???
var $mailCC = "" // CC
var $mailBCC = ""; // ?? ??
var $mailFrom = ""; // ?? ??
var $mailSubject = ""; // ??
var $mailText = ""; format letter body
var $mailHTML = ""; // HTML ??? letter body
var $mailAttachments = ""; // ????
/* ?? setTo($inAddress ): ??? ??? ???? ?? ???? $inAddress
?? ??? ???, ??? ?? ??? ?????. ?? ??? ??? ????? ??? ?????.
?? ?? ?? true???.
**** *********** **************************************** ****/
?? ?? ($inAddress){
//--explosion() ??? ???? ","? ???? ??? ??? ?????.
$addressArray =explore( ",",$inAddress )//- -
for($i=0;$i
//--?? ???? ??? ???
$this->mailTo = implode($addressArray, "," ; Split
$addressArray =explore? ?????. ( ",",$inAddress);
//-??? ?? ??? ??? ???? ?????
for($i=0;$i
//--?? ???? ??? ???
??? ?????. $this->mailCC = implode($ addressArray, ",");
return true; }
/************************************************
?? setCC($inAddress)? ?? ???? ??? ??? ?????.
$inAddress ????? ?? ??? ??? ??, ??? ?? ??? ???? ??????.
?? ??? ??? ????? ??? ?????. ?? true
******************************************** **** ****************/
function setBCC($inAddress){
// --Explode() ??? ???? ?? ","? ???? ? ??? ??
$addressArray =explore( ",",$inAddress)
//--??? ?? ??? ??? ???? ?????.
for($i=0; $i
return false
}
/ /--?? ???? ??? ???
$this->mailBCC = implode($addressArray, ",")
return true
}
/*************************************************
?? setBCC($inAddress)? ?? ?? ??? ?????. $inAddress ????? ?? ???
??? ??? ???? ??????. ??? ?? ??? ??? ???? ?? ??? ??? ?????. > ??
************************************************ **/
function setFrom($inAddress){
if($this->checkEmail($inAddress)){
$this->mailFrom = $ inAddress
return true; ??>} return false }
/**************************************************** * *************
?? setFrom($inAddress): ???? ????? ?? ?? ?? ???? $inAddress? ?????.
?? ???? ?? ?? ?? true???.
* **************************************/
function setSubject($inSubject){
if(strlen(trim($inSubject)) > 0){
$ this->mailSubject = ereg_replace( "n", "",$inSubject);
return true }
return false }
/************************
setSubject($inSubject) ??? ??? ?? ???? $inSubject? ???? ???? ? ?????.
?? ?? ?? true
*******************************************/
function setText( $inText){
if(strlen(trim($inText)) > 0){
$this->mailText = $inText;
return true;
return false; >}
/************************************
?? setHTML($inHTML)? ??? ?? ???? $inHTML? ?????. html ???? html ???? ?? ???,
?? ?? ?? true
******************************** **************/
?? setHTML($inHTML){
if(strlen(trim($inHTML)) > 0){
$this->mailHTML = $ inHTML;
true ?? }
false ?? }
/**************************
?? setAttachments($inAttachments)? ???? ?? ??? ?????. ???? $inAttachments
? ??? ???? ??????. ?? ??? ??? ?????. ?? ?? ?? true
************************** ************** ********/
function setAttachments($inAttachments){
if(strlen(trim($inAttachments)) > 0){
$this->mailAttachments = $inAttachments;
return true; }
return false }
/*******************************
?? checkEmail($inAddress): ??? ? ??? ?? ??? ?? ????. ??
??? ??? ???? ???? ? ?????
************************************ ** ***/
function checkEmail($ inAddress){
return (ereg( "^[^@ ] @([a-zA-Z0-9-] .) ([a-zA-Z0-9-]{2}|net|com|gov |mil|org|edu|int)$",$inAddress));
}
/*************************************************
loadTemplate($inFileLocation,$inHash,$inFormat) ??? ?? ??? ??
???? ?? ????? ?????. $inFileLocation? ??? ????? ?? ? ?????.
$inHash? ?? ? $? ???? ? ?????. inFormat? ??? ??? ???? ? ?????.
****************************************** ********* ***********/
?? loadTemplate($inFileLocation,$inHash,$inFormat){
/* ?? ?? ????? ?? ??? ???? ????. Dear ~!UserName~,
??? ??? ~!UserAddress~???. */
//--??? "~!"? ?? ???? "~ "? ? ?????.
$templateDelim = "~";
$templateNameStart = "!";
//--? ??? ?? ?????.
$templateLineOut = ""; //- -?? ?? ??
if($templateFile = fopen($inFileLocation, "r")){
while(!feof($templateFile)){
$templateLine = fgets($templateFile,1000);
$templateLineArray =explore($templateDelim,$templateLine)
for( $i=0; $i
if(strcspn($templateLineArray[$i],$templateNameStart)==0){
//--?? ? ???
$hashName = substr($templateLineArray[$i],1);
//--?? ? ???
$templateLineArray[$i] = ereg_replace($hashName,(string)$inHash[$hashName],$hashName)
}
}
/ /--?? ?? ? ???? ??
$templateLineOut .= implode($templateLineArray, "")
} //--??? ????.
//- ?? ?? ??(??? ?? html)
if( strtoupper($inFormat)== "TEXT" )
return($this->setText($templateLineOut))
else if( strtoupper( $inFormat)= "HTML" )
return($this->setHTML($templateLineOut))
} return false
}
/*****************************************
getRandomBoundary($offset) ??? ??? ?????. ??? ?? ?
$offset ????? ?????. ?? ????? ??? ???? md5()? ???? ???? ?????.
******************** *** **********************/
function getRandomBoundary( $offset = 0){
//-?? ??
srand(time() $offset)
//-md5? ???? 32?? ?? ?? ??? ??
return ( "----".(md5(rand()))) }
/******************************************
??: getContentType($ inFileName) ?? ?? ??? ???? ? ?????.
***************************************** *** *****/
function getContentType($inFileName){
//-?? path
$inFileName = basename($inFileName);
//--???? ?? ?? ??
if(strrchr($inFileName, ".") == false){
return "application/ ?? ???";
}?
//--提區(qū)擴(kuò)?? 并進(jìn)行判斷?
$extension?=?strrchr($inFileName,?".");?
???($extension){?
case?".gif":?return?"image/gif";?
case?".gz":?"application/x-gzip"? ?????.?
case?".htm":?return?"text/html";?
case?".html":?return?"text/html";?
case?".jpg":?return?"image/jpeg";?
case?".tar":?"application/x-tar"? ?????.?
case?".txt":?"text/plain"? ?????.?
case?".zip":?"application/zip"? ?????.?
???:?"application/octet-stream"? ?????.?
}?
"application/octet-stream"? ?????.?
}?
/**************************************************
?? ??TextHeader ??? ??? ??? ?? ??
************************************** **** **************/?
???formatTextHeader(){?$outTextHeader?=?"";?
$outTextHeader?.=?"??? ??:?text/plain;?
charset=us-asciin";?
$outTextHeader?.=?"??? ??-???:?7bitnn";?
$outTextHeader?.=?$this->mailText.?"N";?
$outTextHeader? ?????.?
}?/************************************************
?? formatHTMLHeader()? html ?? ??? ??? ?? ??? ?????.
********************************** ********/?
???formatHTMLHeader(){?
$outHTMLHeader?=?"";?
$outHTMLHeader?.=?"??? ??:?text/html;?
charset=us-asciin";?
$outHTMLHeader?.=?"??? ?? ???:?7bitnn";?
$outHTMLHeader?.=?$this->mailHTML.?"N";?
$outHTMLHeader? ?????.?
}?
/**************************************
formatAttachmentHeader($inFileLocation) ??? ?? ??? ?????. ???
*************************************/?
?? ??AttachmentHeader($inFileLocation){?
$outAttachmentHeader =?"";? //--如果附件是文本型則用標(biāo)準(zhǔn)的7位編碼?
if(ereg(?"text",$contentType)){?
$outAttachmentHeader?.=?"Content-Type: ".$ contentType.?";N";?
$outAttachmentHeader?.=?'?name="'.basename($inFileLocation).?'"'.?"N";?
$outAttachmentHeader?.=?"??? ?? ???:?7bitn";?
$outAttachmentHeader?.=?"??? ??:??? ??;n";?
$outAttachmentHeader?.=?'?filename="'.basename($inFileLocation).?'"'.?"nn";?
$textFile?=?fopen($inFileLocation,?"r");?
while(!feof($textFile)){?
$outAttachmentHeader?.=?fgets($textFile,1000);?
}?
//--關(guān)閉文件?fclose($textFile);?
$outAttachmentHeader?.=?"n";?
}?
//--?文本格式則用64位進(jìn)行編碼?
else{?$outAttachmentHeader?.=?"??? ??:".$contentType.?";N";?
$outAttachmentHeader?.=?'?name="'.basename($inFileLocation).?'"'.?"N";?
$outAttachmentHeader?.=?"??? ?? ???:?base64n";?
$outAttachmentHeader?.=?"??? ??:??? ??;n";?
$outAttachmentHeader?.=?'?filename="'.basename($inFileLocation).?'"'.?"nn";?
//--調(diào)用??命令uuencode進(jìn)行編碼?
exec(?"uuencode?-m?$inFileLocation?nothing_out",$returnArray);?
($i?=?1;?$i<(count($returnArray));?$i ){?
$outAttachmentHeader?.=?$returnArray[$i].?"N";?
}?
}?$outAttachmentHeader? ?????.?
}
/******************************
send() ??? ???? ??? ? ????, ????? ???? ?? ?? true???.
* *************************************/
function send(){
//--??? ??? ???? ??
$mailHeader = ""
//-CC ??; ???
if($this->mailCC != "")
$mailHeader .= "CC: ".$this->mailCC. "n"
//-?? ?? ??; ?????
if($this->mailBCC != "")
$mailHeader .= "BCC: ".$this->mailBCC
//-?? ???
if($this->mailFrom != "")
$mailHeader .= "FROM: ".$this->mailFrom "n"
//---- ----------??? ??------------ -----
//--??? ??
if($this->mailText != "" && $this->mailHTML == "" && $this->mailAttachments == " "){
return mail($this->mailTo,$this->mailSubject,$this->mailText,$mailHeader);
}
//--html ?? ??? ??
else if($this->mailText != "" && $this->mailHTML != "" && $this->mailAttachments == ""){
$bodyBoundary = $this-> getRandomBoundary();
$textHeader = $this->formatTextHeader();
$htmlHeader = $this->formatHTMLHeader()
//-MIME ?? ??
$mailHeader .= "MIME ??: 1.0n";
$mailHeader .= "??? ??: multipart/alternative;n"
$mailHeader .= 'boundary="'.$bodyBoundary.'"';
$mailHeader .= "nnn";
//-??? ?? ? ?? ??
$mailHeader .= "--".$bodyBoundary.
$mailHeader .= $ textHeader;
$mailHeader .= "--".$bodyBoundary. "n";
//-html ?? ??
$mailHeader .= $mailHeader; --".$bodyBoundary. "--";
//--?? ???
return mail($this->mailTo,$this->mailSubject, "",$mailHeader);
}
//--???? HTML, ?? ??
else if($this->mailText != "" && $this->mailHTML != "" && $this->mailAttachments != ""){
$attachmentBoundary = $this->getRandomBoundary();
$mailHeader .= "Content-Type: multipart/mixed;n"
$mailHeader .= 'boundary="' .$attachmentBoundary. '"'. "nn";
$mailHeader .= "MIME ??? ?? ?? ??????.n";
$mailHeader .= "--".$attachmentBoundary. " n";
$bodyBoundary = $this->getRandomBoundary(1);
$textHeader = $this->formatTextHeader();
$htmlHeader = $this->formatHTMLHeader();
$mailHeader .= "MIME ??: 1.0n";
$mailHeader .= "??? ??: multipart/alternative;n"
$mailHeader .= 'boundary="'.$bodyBoundary. '"';
$mailHeader .= "nnn";
$mailHeader .= "--".$bodyBoundary. "n";
$mailHeader .= $textHeader;
$mailHeader . = "--".$bodyBoundary."n";
$mailHeader .= $htmlHeader .= "n--".$bodyBoundary.
//- -?? ?? ? ????
$attachmentArray =explore( ",",$this->mailAttachments)
//-?? ?? ?? ?? ??
for($i=0;$ i< ;count($attachmentArray);$i ){
//-$mailHeader ?? .= "n--".$attachmentBoundary. "n"
//--???? ??
$ mailHeader .= $this->formatAttachmentHeader($attachmentArray[$i]);
}
$mailHeader .= "--".$attachmentBoundary.
return mail($this - >mailTo,$this->mailSubject, "",$mailHeader)
}
return false
}
}
?> >
?? ??
??? ??? ????.
???? ??? ??? ?????. ??? ??? ?? ??? ??? PHP ??? ??? ??? ???? ???? ????. PHP ????? ??? ?? ????? ??? ??? ????.
“email.class” ??
$mail->setTo("a@a.com") //???
$mail-> "b@b.com,c@c.com"); //??
$mail-> setCC("d@b.com,e@c.com") //??? ??
$mail->setFrom("f@f.com");//???
$mail->setSubject("??") //??
$mail-> ;setText("text format");//??? ??? ??? ??? ? ????
$mail->setHTML("html format");//??? html ??? ??? ? ????
$mail-> ;setAttachments( "c:a.jpg");//???? ??, ??? ???? ?
$mail->send() //??? ???
?>

? AI ??

Undress AI Tool
??? ???? ??

Undresser.AI Undress
???? ?? ??? ??? ?? AI ?? ?

AI Clothes Remover
???? ?? ???? ??? AI ?????.

Clothoff.io
AI ? ???

Video Face Swap
??? ??? AI ?? ?? ??? ???? ?? ???? ??? ?? ????!

?? ??

??? ??

???++7.3.1
???? ?? ?? ?? ???

SublimeText3 ??? ??
??? ??, ???? ?? ????.

???? 13.0.1 ???
??? PHP ?? ?? ??

???? CS6
??? ? ?? ??

SublimeText3 Mac ??
? ??? ?? ?? ?????(SublimeText3)

PHP ?? ??? ?? ???? ?? ? ????? ??? ?????. 1. ?? ??? ??? ??? ??? ? ? ??? ??? ??? ?? ?? ??? ???? ???????. 2. ?? ??? ???? ???? ? ?? ????? ?? ?? ?? ??? ?????. 3. $ _get ? $ _post? ?? Hyperglobal ??? ?? ???? ?? ??? ? ??? ??? ??????? ???????. 4. ?? ?? ?? ???? ?? ?? ?? ??? ?????? ?? ??? ??? ?? ??? ???????. ??? ??? ????? ??? ??? ?? ???? ????? ? ??? ? ? ????.

PHP ?? ???? ???? ????? ?? ? ??? ???? ?? ?? ? ??? ???? ?? ??? ?????? ??? ??? ? ? ???????. 1. ??? ?? CSRF? ???? ?? ??? ??? ???? ?????? ??? ???? FINFO_FILE? ?? ?? MIME ??? ?????. 2. ??? ??? ??? ???? ??? ?? ??? ?? ? WEB ????? ??? ???? ??????. 3. PHP ?? ??? ?? ? ?? ???? NGINX/APACHE? ??? ????? ?? ???? ?????. 4. GD ?????? ??? ? ?? ???? ??? ?? ??? ?? ????.

PHP ?? ???? ? ?? ???? ??? ????. 1. // ?? #? ???? ? ?? ??? ???? // ???? ?? ????. 2. ?? /.../ ?? ?? ?? ??? ????? ?? ? ?? ??? ?? ? ? ????. 3. ?? ?? ?? / if () {} /? ?? ?? ??? ????? ??? ?? ?? ?? ??? ???? ????? ???? ??? ?? ???? ???? ??? ? ??? ??????.

Ageneratorinphpisamemory- ???? Way-Erate-Overgedatasetsetsbaluesoneatimeatimeatimeatimallatonce.1.generatorsuseTheyieldKeywordTocroadtOpvaluesondemand, RetingMemoryUsage.2

PHP ??? ???? ??? ??? ??? ????? ????. ??? ????? ?? ???? ??? "?? ? ?"??? "?"? ???????. 1. ??? ? ??? ??? DocBlock (/*/)? ?? ?? ??? ???? ??? ? ?? ???? ??????. 2. JS ??? ???? ?? ???? ??? ?? ??? ??? ?????. 3. ??? ?? ?? ?? ??? ???? ????? ????? ???? ?? ????? ???? ? ??????. 4. Todo ? Fixme? ????? ???? ? ? ??? ??? ???? ?? ?? ? ??? ???????. ??? ???? ?? ??? ??? ?? ?? ?? ???? ???? ? ????.

tolearnpheffectical, startBysetTupaloCalserErverEnmentUsingToolslikexamppandacodeeditor -likevscode.1) installxamppforapache, mysql, andphp.2) useacodeeditorforsyntaxsupport.3)) 3) testimplephpfile.next, withpluclucincludechlucincluclucludechluclucled

PHP??? ???? ??? ?? ?? ????? ???? ??? ?? ??? ??? ?? ? ??? ??? ???? ?????. ???? 0?? ???? ?? ??? ???? ? ?? ???? ?? ?? ? ? ????. MB_SUBSTR? ?? ??? ??? ???????. ? : $ str = "hello"; echo $ str [0]; ?? H; ??? MB_SUBSTR ($ str, 1,1)? ?? ??? ??? ??? ??????. ?? ???????? ???? ??? ???? ?? ???? ?? ?? ???? ?????? ??? ????? ?? ??? ?? ??? ???? ???? ?? ????.

toinstallphpquickly, usexampponwindowsorhomebrewonmacos.1. ??, downloadandinstallxAmpp, selectComponents, startApache ? placefilesinhtdocs.2
