{"id":23203,"date":"2024-11-21T10:53:36","date_gmt":"2024-11-21T02:53:36","guid":{"rendered":"https:\/\/fwq.ai\/blog\/23203\/"},"modified":"2024-11-21T10:53:36","modified_gmt":"2024-11-21T02:53:36","slug":"thinkphp%e6%80%8e%e4%b9%88%e5%af%bc%e5%85%a5%e7%ac%ac%e4%b8%89%e6%96%b9%e7%b1%bb%e5%ba%93","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/23203\/","title":{"rendered":"ThinkPHP\u600e\u4e48\u5bfc\u5165\u7b2c\u4e09\u65b9\u7c7b\u5e93"},"content":{"rendered":"<p> \u3000\u3000\u7b2c\u4e09\u65b9\u7c7b\u5e93<\/p>\n<p> \u3000\u3000\u7b2c\u4e09\u65b9\u7c7b\u5e93\u6307\u9664\u4e86ThinkPHP\u6846\u67b6\u3001\u5e94\u7528\u9879\u76ee\u7c7b\u5e93\u4e4b\u5916\u7684\u5176\u4ed6\u7c7b\u5e93\uff0c\u4e00\u822c\u7531\u7b2c\u4e09\u65b9\u7cfb\u7edf\u6216\u4ea7\u54c1\u63d0\u4f9b\uff0c\u5982Smarty\u3001Zend\u7b49\u7cfb\u7edf\u7684\u7c7b\u5e93\u7b49\u3002<\/p>\n<p> \u3000\u3000\u524d\u9762\u4f7f\u7528\u81ea\u52a8\u52a0\u8f7d\u6216import\u65b9\u6cd5\u5bfc\u5165\u7684\u7c7b\u5e93\uff0cThinkPHP\u7ea6\u5b9a\u662f\u4ee5.class.php\u4e3a\u540e\u7f00\u7684\uff0c\u975e\u8fd9\u7c7b\u7684\u540e\u7f00\uff0c\u9700\u8981\u901a\u8fc7import\u7684\u53c2\u6570\u6765\u63a7\u5236\u3002<\/p>\n<p> \u3000\u3000\u4f46\u5bf9\u7b2c\u4e09\u7c7b\u5e93\uff0c\u7531\u4e8e\u4e0d\u4f1a\u6709\u6b64\u7ea6\u5b9a\uff0c\u5176\u540e\u7f00\u53ea\u80fd\u8ba4\u4e3a\u662fphp\u3002\u4e3a\u4e86\u65b9\u4fbf\u7684\u5f15\u5165\u5176\u4ed6\u6846\u67b6\u548c\u7cfb\u7edf\u7684\u7c7b\u5e93\uff0cThinkPHP\u7279\u610f\u63d0\u4f9b\u4e86\u5bfc\u5165\u7b2c\u4e09\u65b9\u7c7b\u5e93\u7684\u529f\u80fd\u3002\u7b2c\u4e09\u65b9\u7c7b\u5e93\u7edf\u4e00\u653e\u7f6e\u5728ThinkPHP\u7cfb\u7edf\u76ee\u5f55\/Vendor\u4e0b\u9762\uff0c\u5e76\u4e14\u4f7f\u7528vendor\u65b9\u6cd5\u5bfc\u5165\u3002<\/p>\n<p> \u3000\u3000vendor\u65b9\u6cd5<\/p>\n<p> \u3000\u3000\u8bed\u6cd5\uff1a<\/p>\n<p> \u3000\u3000boolenvendor(class,baseUrl,ext)<\/p>\n<p> \u3000\u3000\u53c2\u6570\u8bf4\u660e\uff1a<\/p>\n<p> \u3000\u3000\u53c2\u6570\u8bf4\u660e<\/p>\n<p> \u3000\u3000class\u5fc5\u987b\uff0c\u8868\u793a\u8981\u5bfc\u5165\u7684\u7c7b\u5e93\uff0c\u91c7\u7528\u547d\u540d\u7a7a\u95f4\u7684\u65b9\u5f0f\u3002<\/p>\n<p> \u3000\u3000baseUrl\u53ef\u9009\uff0c\u8868\u793a\u5bfc\u5165\u7684\u57fa\u7840\u8def\u5f84\uff0c\u7701\u7565\u7684\u8bdd\u7cfb\u7edf\u91c7\u7528ThinkPHP\u7cfb\u7edf\u76ee\u5f55\/Vendor\u76ee\u5f55\u3002<\/p>\n<p> \u3000\u3000ext\u53ef\u9009\uff0c\u8868\u793a\u5bfc\u5165\u7684\u7c7b\u5e93\u540e\u7f00\uff0c\u9ed8\u8ba4\u662f.php\u3002<\/p>\n<p> \u3000\u3000\u4e0eimport\u65b9\u6cd5\u7684\u533a\u522b\u5728\u4e8e\uff0cvendor\u65b9\u6cd5\u9ed8\u8ba4\u7684\u5bfc\u5165\u8def\u5f84\u4e3aThinkPHP\u7cfb\u7edf\u76ee\u5f55\/Vendor\u76ee\u5f55\uff0c\u9ed8\u8ba4\u540e\u7f00\u4e3a.php\u3002<\/p>\n<p> \u3000\u3000\u4e2a\u4eba\u7ecf\u9a8c\u5206\u4eab\uff1a<\/p>\n<p> \u3000\u3000\u5f53\u6211\u4eec\u60f3\u5728ThinkPHP\u4e2d\u5f15\u5165\u7b2c\u4e09\u65b9\u6269\u5c55\uff0c\u800c\u7b2c\u4e09\u65b9\u6269\u5c55\u53c8\u6ca1\u6709\u6309\u7167ThinkPHP\u7684\u89c4\u8303\u5728\u7f16\u5199\u7684\u65f6\u5019\u65f6\uff0c\u5c31\u9700\u8981\u5c06\u7b2c\u4e09\u65b9\u6269\u5c55\u653e\u7f6e\u5230Library\/Vendor\u76ee\u5f55\u4e0b\uff0c\u5f53\u7136\uff0c\u8fd9\u662f\u9488\u5bf9ThinkPHP3.2\u800c\u8a00\uff0c\u4f4e\u7248\u672c\u5219\u6839\u636e\u60c5\u51b5\u6765\u770b\u4e86\u3002<\/p>\n<p> \u3000\u3000\u7136\u540e\u9700\u8981\u5728Controller\u6216function\u4e2d\u4f7f\u7528\u7b2c\u4e09\u65b9\u6269\u5c55\u65f6\uff0c\u5c31\u53ef\u4ee5\u76f4\u63a5\u4f7f\u7528vendor()\u65b9\u6cd5\u6765\u8fdb\u884c\u5f15\u7528\u4e86\u3002<\/p>\n<p> \u3000\u3000\u7b2c\u4e09\u65b9\u7c7b\u5e93\u76ee\u5f55\u7ed3\u6784\uff1a<\/p>\n<p> \u3000\u3000\u5728function\u51fd\u6570\u4e2d\u4f7f\u7528\uff1a<\/p>\n<p> \u3000\u3000\u7b2c\u4e00\u79cd\u65b9\u6cd5\uff1a<\/p>\n<p> \u3000\u3000Vendor(&#8216;Phpqrcode.phpqrcode&#8217;);<\/p>\n<p> \u3000\u3000\u590d\u5236\u4ee3\u7801<\/p>\n<p> \u3000\u3000\u590d\u5236\u4ee3\u7801<\/p>\n<p> \u3000\u3000\/**<\/p>\n<p> \u3000\u3000*\u751f\u6210\u4e8c\u7ef4\u7801<\/p>\n<p> \u3000\u3000*@paramstring$urlurl\u8fde\u63a5<\/p>\n<p> \u3000\u3000*@paraminteger$size\u5c3a\u5bf8\u7eaf\u6570\u5b57<\/p>\n<p> \u3000\u3000*\/<\/p>\n<p> \u3000\u3000functionqrcode($url,$size=4){<\/p>\n<p> \u3000\u3000Vendor(&#8216;Phpqrcode.phpqrcode&#8217;);<\/p>\n<p> \u3000\u3000if(strpos($url,&#8217;http&#8217;)===false){<\/p>\n<p> \u3000\u3000$url=&#8217;http:\/\/&#8217;.$url;<\/p>\n<p> \u3000\u3000}<\/p>\n<p> \u3000\u3000QRcode::png($url,false,QR_ECLEVEL_L,$size,2,false,0xFFFFFF,0x000000);<\/p>\n<p> \u3000\u3000}<\/p>\n<p> \u3000\u3000\u590d\u5236\u4ee3\u7801<\/p>\n<p> \u3000\u3000\u590d\u5236\u4ee3\u7801<\/p>\n<p> \u3000\u3000\u7b2c\u4e8c\u79cd\u65b9\u6cd5\uff1a<\/p>\n<p> \u3000\u3000require&#8217;.\/ThinkPHP\/Library\/Org\/Nx\/class.phpmailer.php&#8217;;<\/p>\n<p> \u3000\u3000require&#8217;.\/ThinkPHP\/Library\/Org\/Nx\/class.smtp.php&#8217;;<\/p>\n<p> \u3000\u3000\u590d\u5236\u4ee3\u7801<\/p>\n<p> \u3000\u3000\u590d\u5236\u4ee3\u7801<\/p>\n<p> \u3000\u3000\/**<\/p>\n<p> \u3000\u3000*\u53d1\u9001\u90ae\u4ef6<\/p>\n<p> \u3000\u3000*@paramstring$address\u9700\u8981\u53d1\u9001\u7684\u90ae\u7bb1\u5730\u5740\u53d1\u9001\u7ed9\u591a\u4e2a\u5730\u5740\u9700\u8981\u5199\u6210\u6570\u7ec4\u5f62\u5f0f<\/p>\n<p> \u3000\u3000*@paramstring$subject\u6807\u9898<\/p>\n<p> \u3000\u3000*@paramstring$content\u5185\u5bb9<\/p>\n<p> \u3000\u3000*@returnboolean\u662f\u5426\u6210\u529f<\/p>\n<p> \u3000\u3000*\/<\/p>\n<p> \u3000\u3000functionsend_email($address,$subject,$content){<\/p>\n<p> \u3000\u3000$email_smtp=C(&#8216;EMAIL_SMTP&#8217;);<\/p>\n<p> \u3000\u3000$email_username=C(&#8216;EMAIL_USERNAME&#8217;);<\/p>\n<p> \u3000\u3000$email_password=C(&#8216;EMAIL_PASSWORD&#8217;);<\/p>\n<p> \u3000\u3000$email_from_name=C(&#8216;EMAIL_FROM_NAME&#8217;);<\/p>\n<p> \u3000\u3000if(empty($email_smtp)||empty($email_username)||empty($email_password)||empty($email_from_name)){<\/p>\n<p> \u3000\u3000returnarray(&#8220;error&#8221;=&gt;1,&#8221;message&#8221;=&gt;&#8217;\u90ae\u7bb1\u914d\u7f6e\u4e0d\u5b8c\u6574&#8217;);<\/p>\n<p> \u3000\u3000}<\/p>\n<p> \u3000\u3000require&#8217;.\/ThinkPHP\/Library\/Org\/Nx\/class.phpmailer.php&#8217;;<\/p>\n<p> \u3000\u3000require&#8217;.\/ThinkPHP\/Library\/Org\/Nx\/class.smtp.php&#8217;;<\/p>\n<p> \u3000\u3000$phpmailer=newPhpmailer();<\/p>\n<p> \u3000\u3000\/\/\u8bbe\u7f6ePHPMailer\u4f7f\u7528SMTP\u670d\u52a1\u5668\u53d1\u9001Email<\/p>\n<p> \u3000\u3000$phpmailer-&gt;IsSMTP();<\/p>\n<p> \u3000\u3000\/\/\u8bbe\u7f6e\u4e3ahtml\u683c\u5f0f<\/p>\n<p> \u3000\u3000$phpmailer-&gt;IsHTML(true);<\/p>\n<p> \u3000\u3000\/\/\u8bbe\u7f6e\u90ae\u4ef6\u7684\u5b57\u7b26\u7f16\u7801&#8217;<\/p>\n<p> \u3000\u3000$phpmailer-&gt;CharSet=&#8217;UTF-8&#8242;;<\/p>\n<p> \u3000\u3000\/\/\u8bbe\u7f6eSMTP\u670d\u52a1\u5668\u3002<\/p>\n<p> \u3000\u3000$phpmailer-&gt;Host=$email_smtp;<\/p>\n<p> \u3000\u3000\/\/\u8bbe\u7f6e\u4e3a&#8221;\u9700\u8981\u9a8c\u8bc1&#8221;<\/p>\n<p> \u3000\u3000$phpmailer-&gt;SMTPAuth=true;<\/p>\n<p> \u3000\u3000\/\/\u8bbe\u7f6e\u7528\u6237\u540d<\/p>\n<p> \u3000\u3000$phpmailer-&gt;Username=$email_username;<\/p>\n<p> \u3000\u3000\/\/\u8bbe\u7f6e\u5bc6\u7801<\/p>\n<p> \u3000\u3000$phpmailer-&gt;Password=$email_password;<\/p>\n<p> \u3000\u3000\/\/\u8bbe\u7f6e\u90ae\u4ef6\u5934\u7684From\u5b57\u6bb5\u3002<\/p>\n<p> \u3000\u3000$phpmailer-&gt;From=$email_username;<\/p>\n<p> \u3000\u3000\/\/\u8bbe\u7f6e\u53d1\u4ef6\u4eba\u540d\u5b57<\/p>\n<p> \u3000\u3000$phpmailer-&gt;FromName=$email_from_name;<\/p>\n<p> \u3000\u3000\/\/\u6dfb\u52a0\u6536\u4ef6\u4eba\u5730\u5740\uff0c\u53ef\u4ee5\u591a\u6b21\u4f7f\u7528\u6765\u6dfb\u52a0\u591a\u4e2a\u6536\u4ef6\u4eba<\/p>\n<p> \u3000\u3000if(is_array($address)){<\/p>\n<p> \u3000\u3000foreach($addressas$addressv){<\/p>\n<p> \u3000\u3000$phpmailer-&gt;AddAddress($addressv);<\/p>\n<p> \u3000\u3000}<\/p>\n<p> \u3000\u3000}else{<\/p>\n<p> \u3000\u3000$phpmailer-&gt;AddAddress($address);<\/p>\n<p> \u3000\u3000}<\/p>\n<p> \u3000\u3000\/\/\u8bbe\u7f6e\u90ae\u4ef6\u6807\u9898<\/p>\n<p> \u3000\u3000$phpmailer-&gt;Subject=$subject;<\/p>\n<p> \u3000\u3000\/\/\u8bbe\u7f6e\u90ae\u4ef6\u6b63\u6587<\/p>\n<p> \u3000\u3000$phpmailer-&gt;Body=$content;<\/p>\n<p> \u3000\u3000\/\/\u53d1\u9001\u90ae\u4ef6\u3002<\/p>\n<p> \u3000\u3000if(!$phpmailer-&gt;Send()){<\/p>\n<p> \u3000\u3000$phpmailererror=$phpmailer-&gt;ErrorInfo;<\/p>\n<p> \u3000\u3000returnarray(&#8220;error&#8221;=&gt;1,&#8221;message&#8221;=&gt;$phpmailererror);<\/p>\n<p> \u3000\u3000}else{<\/p>\n<p> \u3000\u3000returnarray(&#8220;error&#8221;=&gt;0);<\/p>\n<p> \u3000\u3000}<\/p>\n<p> \u3000\u3000}<\/p>\n<p> \u3000\u3000\u590d\u5236\u4ee3\u7801<\/p>\n<p> \u3000\u3000\u590d\u5236\u4ee3\u7801<\/p>\n<p> \u3000\u3000\u7b2c\u4e09\u79cd\u65b9\u6cd5\uff1a<\/p>\n<p> \u3000\u3000\u652f\u4ed8\u5b9d\u7c7b\u5e93\u76ee\u5f55\u7ed3\u6784<\/p>\n<p> \u3000\u3000vendor(&#8216;Alipay.AlipaySubmit&#8217;,&#8221;,&#8217;.class.php&#8217;);<\/p>\n<p> \u3000\u3000\u6ce8\u610f\u8bf4\u660e\uff1aVendor\u52a0\u8f7d\u7684\u9ed8\u8ba4\u540e\u7f00\u662f.php\u7684<\/p>\n<p> \u3000\u3000\u53c2\u6570\u4e00\uff1a\u5fc5\u987b\uff0c\u8868\u793a\u8981\u5bfc\u5165\u7684\u7c7b\u5e93\uff0c\u91c7\u7528\u547d\u540d\u7a7a\u95f4\u7684\u65b9\u5f0f<\/p>\n<p> \u3000\u3000\u53c2\u6570\u4e8c\uff1a\u53ef\u9009\uff0c\u8868\u793a\u5bfc\u5165\u7684\u57fa\u7840\u8def\u5f84\uff0c\u7701\u7565\u7684\u8bdd\u7cfb\u7edf\u91c7\u7528ThinkPHP\u7cfb\u7edf\u76ee\u5f55\/Vendor\u76ee\u5f55\u3002<\/p>\n<p> \u3000\u3000\u53c2\u6570\u4e09\uff1a\u53ef\u9009\uff0c\u8868\u793a\u5bfc\u5165\u7684\u7c7b\u5e93\u540e\u7f00\uff0c\u9ed8\u8ba4\u662f.php\u3002<\/p>\n<p> \u3000\u3000\u652f\u4ed8\u5b9d\u7b2c\u4e09\u65b9\u6848\u4f8b\u4ee3\u7801\uff1a<\/p>\n<p> \u3000\u3000\u590d\u5236\u4ee3\u7801<\/p>\n<p> \u3000\u3000\u590d\u5236\u4ee3\u7801<\/p>\n<p> \u3000\u3000\/**<\/p>\n<p> \u3000\u3000*\u8df3\u5411\u652f\u4ed8\u5b9d\u4ed8\u6b3e<\/p>\n<p> \u3000\u3000*@paramarray$order\u8ba2\u5355\u6570\u636e\u5fc5\u987b\u5305\u542bout_trade_no(\u8ba2\u5355\u53f7)\u3001price(\u8ba2\u5355\u91d1\u989d)\u3001subject(\u5546\u54c1\u540d\u79f0\u6807\u9898)<\/p>\n<p> \u3000\u3000*\/<\/p>\n<p> \u3000\u3000functionalipay($order){<\/p>\n<p> \u3000\u3000vendor(&#8216;Alipay.AlipaySubmit&#8217;,&#8221;,&#8217;.class.php&#8217;);<\/p>\n<p> \u3000\u3000\/\/\u83b7\u53d6\u914d\u7f6e<\/p>\n<p> \u3000\u3000$config=C(&#8216;ALIPAY_CONFIG&#8217;);<\/p>\n<p> \u3000\u3000$data=array(<\/p>\n<p> \u3000\u3000&#8221;_input_charset&#8221;=&gt;$config[&#8216;input_charset&#8217;],\/\/\u7f16\u7801\u683c\u5f0f<\/p>\n<p> \u3000\u3000&#8221;logistics_fee&#8221;=&gt;&#8221;0.00&#8243;,\/\/\u7269\u6d41\u8d39\u7528<\/p>\n<p> \u3000\u3000&#8221;logistics_payment&#8221;=&gt;&#8221;SELLER_PAY&#8221;,\/\/\u7269\u6d41\u652f\u4ed8\u65b9\u5f0fSELLER_PAY\uff08\u5356\u5bb6\u627f\u62c5\u8fd0\u8d39\uff09\u3001BUYER_PAY\uff08\u4e70\u5bb6\u627f\u62c5\u8fd0\u8d39\uff09<\/p>\n<p> \u3000\u3000&#8221;logistics_type&#8221;=&gt;&#8221;EXPRESS&#8221;,\/\/\u7269\u6d41\u7c7b\u578bEXPRESS\uff08\u5feb\u9012\uff09\u3001POST\uff08\u5e73\u90ae\uff09\u3001EMS\uff08EMS\uff09<\/p>\n<p> \u3000\u3000&#8221;notify_url&#8221;=&gt;$config[&#8216;notify_url&#8217;],\/\/\u5f02\u6b65\u63a5\u6536\u652f\u4ed8\u72b6\u6001\u901a\u77e5\u7684\u94fe\u63a5<\/p>\n<p> \u3000\u3000&#8221;out_trade_no&#8221;=&gt;$order[&#8216;out_trade_no&#8217;],\/\/\u8ba2\u5355\u53f7<\/p>\n<p> \u3000\u3000&#8221;partner&#8221;=&gt;$config[&#8216;partner&#8217;],\/\/partner\u4ece\u652f\u4ed8\u5b9d\u5546\u6237\u7248\u4e2a\u4eba\u4e2d\u5fc3\u83b7\u53d6<\/p>\n<p> \u3000\u3000&#8221;payment_type&#8221;=&gt;&#8221;1&#8243;,\/\/\u652f\u4ed8\u7c7b\u578b\u5bf9\u5e94\u8bf7\u6c42\u65f6\u7684payment_type\u53c2\u6570,\u539f\u6837\u8fd4\u56de\u3002\u56fa\u5b9a\u8bbe\u7f6e\u4e3a1\u5373\u53ef<\/p>\n<p> \u3000\u3000&#8221;price&#8221;=&gt;$order[&#8216;price&#8217;],\/\/\u8ba2\u5355\u4ef7\u683c\u5355\u4f4d\u4e3a\u5143<\/p>\n<p> \u3000\u3000\/\/&#8221;price&#8221;=&gt;0.01,\/\/\/\/\u8c03\u4ef7\u7528\u4e8e\u6d4b\u8bd5<\/p>\n<p> \u3000\u3000&#8221;quantity&#8221;=&gt;&#8221;1&#8243;,\/\/price\u3001quantity\u80fd\u4ee3\u66fftotal_fee\u3002\u5373\u5b58\u5728total_fee,\u5c31\u4e0d\u80fd\u5b58\u5728price\u548cquantity;\u5b58\u5728price\u3001quantity,\u5c31\u4e0d\u80fd\u5b58\u5728total_fee\u3002\uff08\u6ca1\u7ed5\u660e\u767d\uff1b\u597d\u5427\uff1b\u90a3\u65e0\u89c6\u8fd9\u4e2a\u53c2\u6570\u5373\u53ef\uff09<\/p>\n<p> \u3000\u3000&#8221;receive_address&#8221;=&gt;&#8217;1&#8242;,\/\/\u6536\u8d27\u4eba\u5730\u5740\u5373\u65f6\u5230\u8d26\u65b9\u5f0f\u65e0\u89c6\u6b64\u53c2\u6570\u5373\u53ef<\/p>\n<p> \u3000\u3000&#8221;receive_mobile&#8221;=&gt;&#8217;1&#8242;,\/\/\u6536\u8d27\u4eba\u624b\u673a\u53f7\u7801\u5373\u65f6\u5230\u8d26\u65b9\u5f0f\u65e0\u89c6\u5373\u53ef<\/p>\n<p> \u3000\u3000&#8221;receive_name&#8221;=&gt;&#8217;1&#8242;,\/\/\u6536\u8d27\u4eba\u59d3\u540d\u5373\u65f6\u5230\u8d26\u65b9\u5f0f\u65e0\u89c6\u5373\u53ef<\/p>\n<p> \u3000\u3000&#8221;receive_zip&#8221;=&gt;&#8217;1&#8242;,\/\/\u6536\u8d27\u4eba\u90ae\u7f16\u5373\u65f6\u5230\u8d26\u65b9\u5f0f\u65e0\u89c6\u5373\u53ef<\/p>\n<p> \u3000\u3000&#8221;return_url&#8221;=&gt;$config[&#8216;return_url&#8217;],\/\/\u9875\u9762\u8df3\u8f6c\u540c\u6b65\u901a\u77e5\u9875\u9762\u8def\u5f84\u652f\u4ed8\u5b9d\u5904\u7406\u5b8c\u8bf7\u6c42\u540e,\u5f53\u524d\u9875\u9762\u81ea\u52a8\u8df3\u8f6c\u5230\u5546\u6237\u7f51\u7ad9\u91cc\u6307\u5b9a\u9875\u9762\u7684http\u8def\u5f84\u3002<\/p>\n<p> \u3000\u3000&#8221;seller_email&#8221;=&gt;$config[&#8216;seller_email&#8217;],\/\/email\u4ece\u652f\u4ed8\u5b9d\u5546\u6237\u7248\u4e2a\u4eba\u4e2d\u5fc3\u83b7\u53d6<\/p>\n<p> \u3000\u3000&#8221;service&#8221;=&gt;&#8221;create_direct_pay_by_user&#8221;,\/\/\u63a5\u53e3\u540d\u79f0\u56fa\u5b9a\u8bbe\u7f6e\u4e3acreate_direct_pay_by_user<\/p>\n<p> \u3000\u3000&#8221;show_url&#8221;=&gt;$config[&#8216;show_url&#8217;],\/\/\u5546\u54c1\u5c55\u793a\u7f51\u5740,\u6536\u94f6\u53f0\u9875\u9762\u4e0a,\u5546\u54c1\u5c55\u793a\u7684\u8d85\u94fe\u63a5\u3002<\/p>\n<p> \u3000\u3000&#8221;subject&#8221;=&gt;$order[&#8216;subject&#8217;]\/\/\u5546\u54c1\u540d\u79f0\u5546\u54c1\u7684\u6807\u9898\/\u4ea4\u6613\u6807\u9898\/\u8ba2\u5355\u6807\u9898\/\u8ba2\u5355\u5173\u952e\u5b57\u7b49<\/p>\n<p> \u3000\u3000);<\/p>\n<p> \u3000\u3000$alipay=newAlipaySubmit($config);<\/p>\n<p> \u3000\u3000$new=$alipay-&gt;buildRequestPara($data);<\/p>\n<p> \u3000\u3000$go_pay=$alipay-&gt;buildRequestForm($new,&#8217;get&#8217;,&#8217;\u652f\u4ed8&#8217;);<\/p>\n<p> \u3000\u3000echo$go_pay;<\/p>\n<p> \u3000\u3000}<\/p>\n<p> \u3000\u3000\u590d\u5236\u4ee3\u7801<\/p>\n<p> \u3000\u3000\u590d\u5236\u4ee3\u7801<\/p>\n<p> \u3000\u3000\u4e0d\u8fc7\u5f53\u6211\u5c06PHPMailer\u653e\u5728Vendor\u76ee\u5f55\u4e0b\u540e\uff0c\u5728\u672c\u673a\u8fd0\u884c\u5f97\u597d\u597d\u5f97\uff0c\u6700\u8fd1\u5c06\u7a0b\u5e8f\u4e0a\u4f20\u5230\u670d\u52a1\u5668\u4e0a\u65f6\uff0c\u76f4\u63a5\u63d0\u793aClass\u2018PHPMailer\u2019notfound\u7136\u540e\u53c8\u5728\u672c\u673a\u8fd0\u884c\uff0c\u8fd8\u662f\u6b63\u786e\uff01\u901a\u8fc7\u524d\u9762\u8fd9\u7247\u535a\u5ba2\u53ef\u4ee5\u77e5\u9053\uff0c\u6211\u662f\u901a\u8fc7vendor(&#8216;PHPMailer.class#PHPMailer&#8217;);<\/p>\n<p> \u3000\u3000\u8fd9\u884c\u4ee3\u7801\u5c06PHPMailer\u5f15\u5165\u7684\u3002\u65e2\u7136\u63d0\u793a\u627e\u4e0d\u5230PHPMailer\u7c7b\uff0c\u8bf4\u660e\u6ca1\u6709\u88ab\u6b63\u786e\u5f15\u5165\u3002\u8fd9\u662f\u4e3a\u4ec0\u4e48\u5462\uff1f<\/p>\n<p> \u3000\u3000\u5c31\u7c97\u7565\u770b\u4e86\u4e00\u4e0bvendor()\u65b9\u6cd5\u7684\u6e90\u7801\uff0c\u8fd9\u624d\u53d1\u73b0\u5176\u5b9evendor()\u65b9\u6cd5\u4e5f\u5c31\u662f\u5bf9import()\u65b9\u6cd5\u8fdb\u884c\u4e86\u4e00\u6b21\u53c2\u6570\u7ec4\u88c5\uff0c\u7136\u540e\u8fd8\u662f\u4ea4\u7ed9\u4e86import()\u65b9\u6cd5\u5904\u7406\u3002\u67e5\u770bimport()\u65b9\u6cd5\u7684\u6e90\u7801\u53c8\u53d1\u73b0\uff0c\u5728import()\u65b9\u6cd5\u4e2d\uff0c\u5bf9\u4e8e\u4e0a\u9762\u4f20\u5165\u53c2\u6570\u7684\u89e3\u6790\u5176\u5b9e\u5c31\u662f\u5c06\u2019.\u2019\u66ff\u6362\u6210\u2019\/\u2019\uff0c\u5c06\u2019#\u2019\u66ff\u6362\u6210\u4e86\u2019.\u2019\uff0cbaseurl\u5219\u7531vendor()\u65b9\u6cd5\u81ea\u52a8\u8865\u5145\u4e0a\u4e86\uff0c\u6307\u5411Vendor\u76ee\u5f55\u3002\u6240\u4ee5\u4e0a\u9762vendor()\u65b9\u6cd5\u4e2d\u7684\u53c2\u6570\u6700\u7ec8\u8fd8\u662f\u88ab\u89e3\u6790\u6210\u4e86\u5982\u4e0b\u76ee\u5f55\uff1a<\/p>\n<p> \u3000\u3000Library\/Vendor\/PHPMailer\/class.PHPMailer.php<\/p>\n<p> \u3000\u3000\u800cPHPMailer\u7684\u5165\u53e3\u6587\u4ef6\u7684\u5b9e\u9645\u76ee\u5f55\u5730\u5740\u4e3a\uff1a<\/p>\n<p> \u3000\u3000Library\/Vendor\/phpmailer\/class.phpmailer.php<\/p>\n<p> \u3000\u3000\u5185\u5bb9\u90fd\u4e00\u6837\u7684\u561b\uff01\u4e0d\u8fc7\u6211\u7528\u7684\u662fLinux\u7684\u670d\u52a1\u5668\uff0c\u6240\u4ee5\u5bf9\u5927\u5c0f\u5199\u662f\u4e25\u683c\u533a\u5206\u7684\uff0c\u8fd9\u6837\u5f53\u7136\u4e0d\u80fd\u6210\u529f\u5bfc\u5165\u8fd9\u4e2a\u7c7b\u3002\u800c\u89e3\u51b3\u529e\u6cd5\u5c31\u662f\u5c06vendor()\u5f15\u5165\u6539\u4e3a\uff1a<\/p>\n<p> \u3000\u3000vendor(\u2018phpmailer.class#phpmailer\u2019)<\/p>\n<p> \u3000\u3000\u53e6\u5916\u5bf9\u4e8ePHPMailer\u4f7f\u7528\u65f6\u8fd8\u8981\u6ce8\u610f\u4e00\u70b9\uff0cPHPMailer\u5982\u679c\u4f7f\u7528SMTP\u65b9\u5f0f\u53d1\u9001\u90ae\u4ef6\uff0c\u9700\u8981PHP\u5bf9fsockopen\u7684\u652f\u6301\uff0c\u6240\u4ee5\u6211\u4eec\u9700\u8981\u4fee\u6539php.ini\u4e2ddisable_functions\u4e2d\u5c06fscokopen\u5220\u9664\uff0c\u5426\u5219\u4f1a\u51fa\u73b0\u8fd0\u884c\u9519\u8bef\uff1a<\/p>\n<p> \u3000\u3000fsockopen()hasbeendisabled<\/p>\n<p> \u3000\u3000\u901a\u8fc7PHPMailer\u7684ErrorInfo\u5c5e\u6027\u53ef\u4ee5\u83b7\u53d6\u5230\uff01<\/p>\n<p>\u4ee5\u4e0a\u5c31\u662fThinkPHP\u600e\u4e48\u5bfc\u5165\u7b2c\u4e09\u65b9\u7c7b\u5e93\u7684\u8be6\u7ec6\u5185\u5bb9\uff0c\u66f4\u591a\u8bf7\u5173\u6ce8\u7c73\u4e91\u5176\u5b83\u76f8\u5173\u6587\u7ae0\uff01<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u3000\u3000\u7b2c\u4e09\u65b9\u7c7b\u5e93 \u3000\u3000\u7b2c\u4e09\u65b9\u7c7b\u5e93\u6307\u9664\u4e86ThinkPHP\u6846\u67b6\u3001\u5e94\u7528\u9879\u76ee\u7c7b\u5e93\u4e4b\u5916\u7684\u5176\u4ed6\u7c7b\u5e93\uff0c\u4e00\u822c\u7531\u7b2c\u4e09\u65b9\u7cfb\u7edf\u6216\u4ea7\u54c1\u63d0\u4f9b\uff0c\u5982Smarty\u3001Zend\u7b49\u7cfb\u7edf\u7684\u7c7b\u5e93\u7b49\u3002 \u3000\u3000\u524d\u9762\u4f7f\u7528\u81ea\u52a8\u52a0\u8f7d\u6216import\u65b9\u6cd5\u5bfc\u5165\u7684\u7c7b\u5e93\uff0cThinkPHP\u7ea6\u5b9a\u662f\u4ee5.class.php\u4e3a\u540e\u7f00\u7684\uff0c\u975e\u8fd9\u7c7b\u7684\u540e\u7f00\uff0c\u9700\u8981\u901a\u8fc7import\u7684\u53c2\u6570\u6765\u63a7\u5236\u3002 \u3000\u3000\u4f46\u5bf9\u7b2c\u4e09\u7c7b\u5e93\uff0c\u7531\u4e8e\u4e0d\u4f1a\u6709\u6b64\u7ea6\u5b9a\uff0c\u5176\u540e\u7f00\u53ea\u80fd\u8ba4\u4e3a\u662fphp\u3002\u4e3a\u4e86\u65b9\u4fbf\u7684\u5f15\u5165\u5176\u4ed6\u6846\u67b6\u548c\u7cfb\u7edf\u7684\u7c7b\u5e93\uff0cThinkPHP\u7279\u610f\u63d0\u4f9b\u4e86\u5bfc\u5165\u7b2c\u4e09\u65b9\u7c7b\u5e93\u7684\u529f\u80fd\u3002\u7b2c\u4e09\u65b9\u7c7b\u5e93\u7edf\u4e00\u653e\u7f6e\u5728ThinkPHP\u7cfb\u7edf\u76ee\u5f55\/Vendor\u4e0b\u9762\uff0c\u5e76\u4e14\u4f7f\u7528vendor\u65b9\u6cd5\u5bfc\u5165\u3002 \u3000\u3000vendor\u65b9\u6cd5 \u3000\u3000\u8bed\u6cd5\uff1a \u3000\u3000boolenvendor(class,baseUrl,ext) \u3000\u3000\u53c2\u6570\u8bf4\u660e\uff1a \u3000\u3000\u53c2\u6570\u8bf4\u660e \u3000\u3000class\u5fc5\u987b\uff0c\u8868\u793a\u8981\u5bfc\u5165\u7684\u7c7b\u5e93\uff0c\u91c7\u7528\u547d\u540d\u7a7a\u95f4\u7684\u65b9\u5f0f\u3002 \u3000\u3000baseUrl\u53ef\u9009\uff0c\u8868\u793a\u5bfc\u5165\u7684\u57fa\u7840\u8def\u5f84\uff0c\u7701\u7565\u7684\u8bdd\u7cfb\u7edf\u91c7\u7528ThinkPHP\u7cfb\u7edf\u76ee\u5f55\/Vendor\u76ee\u5f55\u3002 \u3000\u3000ext\u53ef\u9009\uff0c\u8868\u793a\u5bfc\u5165\u7684\u7c7b\u5e93\u540e\u7f00\uff0c\u9ed8\u8ba4\u662f.php\u3002 \u3000\u3000\u4e0eimport\u65b9\u6cd5\u7684\u533a\u522b\u5728\u4e8e\uff0cvendor\u65b9\u6cd5\u9ed8\u8ba4\u7684\u5bfc\u5165\u8def\u5f84\u4e3aThinkPHP\u7cfb\u7edf\u76ee\u5f55\/Vendor\u76ee\u5f55\uff0c\u9ed8\u8ba4\u540e\u7f00\u4e3a.php\u3002 \u3000\u3000\u4e2a\u4eba\u7ecf\u9a8c\u5206\u4eab\uff1a \u3000\u3000\u5f53\u6211\u4eec\u60f3\u5728ThinkPHP\u4e2d\u5f15\u5165\u7b2c\u4e09\u65b9\u6269\u5c55\uff0c\u800c\u7b2c\u4e09\u65b9\u6269\u5c55\u53c8\u6ca1\u6709\u6309\u7167ThinkPHP\u7684\u89c4\u8303\u5728\u7f16\u5199\u7684\u65f6\u5019\u65f6\uff0c\u5c31\u9700\u8981\u5c06\u7b2c\u4e09\u65b9\u6269\u5c55\u653e\u7f6e\u5230Library\/Vendor\u76ee\u5f55\u4e0b\uff0c\u5f53\u7136\uff0c\u8fd9\u662f\u9488\u5bf9ThinkPHP3.2\u800c\u8a00\uff0c\u4f4e\u7248\u672c\u5219\u6839\u636e\u60c5\u51b5\u6765\u770b\u4e86\u3002 \u3000\u3000\u7136\u540e\u9700\u8981\u5728Controller\u6216function\u4e2d\u4f7f\u7528\u7b2c\u4e09\u65b9\u6269\u5c55\u65f6\uff0c\u5c31\u53ef\u4ee5\u76f4\u63a5\u4f7f\u7528vendor()\u65b9\u6cd5\u6765\u8fdb\u884c\u5f15\u7528\u4e86\u3002 \u3000\u3000\u7b2c\u4e09\u65b9\u7c7b\u5e93\u76ee\u5f55\u7ed3\u6784\uff1a \u3000\u3000\u5728function\u51fd\u6570\u4e2d\u4f7f\u7528\uff1a \u3000\u3000\u7b2c\u4e00\u79cd\u65b9\u6cd5\uff1a \u3000\u3000Vendor(&#8216;Phpqrcode.phpqrcode&#8217;); \u3000\u3000\u590d\u5236\u4ee3\u7801 \u3000\u3000\u590d\u5236\u4ee3\u7801 \u3000\u3000\/** \u3000\u3000*\u751f\u6210\u4e8c\u7ef4\u7801 \u3000\u3000*@paramstring$urlurl\u8fde\u63a5 \u3000\u3000*@paraminteger$size\u5c3a\u5bf8\u7eaf\u6570\u5b57 \u3000\u3000*\/ \u3000\u3000functionqrcode($url,$size=4){ \u3000\u3000Vendor(&#8216;Phpqrcode.phpqrcode&#8217;); \u3000\u3000if(strpos($url,&#8217;http&#8217;)===false){ \u3000\u3000$url=&#8217;http:\/\/&#8217;.$url; \u3000\u3000} \u3000\u3000QRcode::png($url,false,QR_ECLEVEL_L,$size,2,false,0xFFFFFF,0x000000); \u3000\u3000} \u3000\u3000\u590d\u5236\u4ee3\u7801 \u3000\u3000\u590d\u5236\u4ee3\u7801 \u3000\u3000\u7b2c\u4e8c\u79cd\u65b9\u6cd5\uff1a \u3000\u3000require&#8217;.\/ThinkPHP\/Library\/Org\/Nx\/class.phpmailer.php&#8217;; \u3000\u3000require&#8217;.\/ThinkPHP\/Library\/Org\/Nx\/class.smtp.php&#8217;; \u3000\u3000\u590d\u5236\u4ee3\u7801 \u3000\u3000\u590d\u5236\u4ee3\u7801 \u3000\u3000\/** \u3000\u3000*\u53d1\u9001\u90ae\u4ef6 \u3000\u3000*@paramstring$address\u9700\u8981\u53d1\u9001\u7684\u90ae\u7bb1\u5730\u5740\u53d1\u9001\u7ed9\u591a\u4e2a\u5730\u5740\u9700\u8981\u5199\u6210\u6570\u7ec4\u5f62\u5f0f \u3000\u3000*@paramstring$subject\u6807\u9898 \u3000\u3000*@paramstring$content\u5185\u5bb9 \u3000\u3000*@returnboolean\u662f\u5426\u6210\u529f \u3000\u3000*\/ \u3000\u3000functionsend_email($address,$subject,$content){ \u3000\u3000$email_smtp=C(&#8216;EMAIL_SMTP&#8217;); \u3000\u3000$email_username=C(&#8216;EMAIL_USERNAME&#8217;); \u3000\u3000$email_password=C(&#8216;EMAIL_PASSWORD&#8217;); \u3000\u3000$email_from_name=C(&#8216;EMAIL_FROM_NAME&#8217;); \u3000\u3000if(empty($email_smtp)||empty($email_username)||empty($email_password)||empty($email_from_name)){ \u3000\u3000returnarray(&#8220;error&#8221;=&gt;1,&#8221;message&#8221;=&gt;&#8217;\u90ae\u7bb1\u914d\u7f6e\u4e0d\u5b8c\u6574&#8217;); [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[16],"tags":[],"class_list":["post-23203","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/23203","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/comments?post=23203"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/23203\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=23203"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=23203"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=23203"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}