《Disney +》 迪士尼、Marvel、彼思、星球大戰…  DelightWorks設立新公司「株式会社ラセングル」繼承所有包括FGO等的遊戲事業   索尼克的完全新作《索尼克未知邊境》將於2022年冬季登場!   Nintendo Switch「薩爾達傳說 天空之劍 HD」將於2021年7月16日起開始販售!特殊設計款Joy-Con同步開賣!   最高降價超過一萬日幣!高CP值的HyperX電競耳麥將改成更親民的價格!   鳥取與奈及利亞連結!電競活動「TNED2021」同時於兩地展開!   《Cuphead》的《The Delicious Last Course》DLC將於2022年6月30日登陸PS4   《地平線 西域禁地》新影片披露滑行獸、捲背獸和日翼者等駭人新機器   為紀念「第88回 東京優駿(GI)」KONAMI全面監製的桃鐵風賽馬雙陸遊戲「桃太郎電鐵優駿」公開! 

PHP 符合 RFC 規範的 Email 驗證程式

商業
800px-php-n_logosvg 要驗證 Email 是否符合規格, 大部分是使用下面的簡單 Regular expression 來作驗證 (下面兩者 regex 是一樣的, 只是 php / rails 版的寫法而已)
  • preg_match('/^([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})$/', $email) // 正確: true, 錯誤: false
  • validates_format_of :email, :with => /^([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})$/i, :message => '格式錯誤'
使用上述的檢查後, 再加上 PHP 驗證 Email -檢查 DNS 的 MX 是否有通, 再來就該直接寄信去驗證了. 在前面那段 regex 的驗證, Dominic Sayers 把 RFC 1123, 2396, 3696, 4291, 4343, 5321 & 5322 看完, 寫出下面的 PHP function, 此 function 也有附上 unit test 的測試資料, 是我看過最複雜的檢查了. XD 轉載此 Function: (Source: RFC-compliant email address validator) 描述: A PHP function that validates all parts of a given email address, according to RFCs 1123, 2396, 3696, 4291, 4343, 5321 & 5322. I’ve released it under a license that allows you to use it royalty-free in commercial or non-commercial work, subject to a few conditions. It’s almost certainly the first email address validator that correctly lets you put an IPv6 address in for the domain part. Source

隨機商業新聞