PHP Cookbook读书笔记 – 第09章表单
Jun 06, 2016 pm 07:40 PM本章的内容可以说是上一章节的延续,因为表单也是web的基础,但同时也是web基础中的重要组成部分。本章重点介绍了表单中可能出现的各项表单元素的验证、文件上传以及相关的安全问题。 $_SERVER['REQUEST_METHOD']:检测请求是GET还是POST 验证email地址是否
本章的内容可以说是上一章节的延续,因为表单也是web的基础,但同时也是web基础中的重要组成部分。本章重点介绍了表单中可能出现的各项表单元素的验证、文件上传以及相关的安全问题。
$_SERVER['REQUEST_METHOD']:检测请求是GET还是POST
验证email地址是否有效的函数:
function is_valid_email_address($email){ $qtext = '[^\\x0d\\x22\\x5c\\x80-\\xff]'; $dtext = '[^\\x0d\\x5b-\\x5d\\x80-\\xff]'; $atom = '[^\\x00-\\x20\\x22\\x28\\x29\\x2c\\x2e\\x3a-\\x3c'. '\\x3e\\x40\\x5b-\\x5d\\x7f-\\xff]+'; $quoted_pair = '\\x5c[\\x00-\\x7f]'; $domain_literal = "\\x5b($dtext|$quoted_pair)*\\x5d"; $quoted_string = "\\x22($qtext|$quoted_pair)*\\x22"; $domain_ref = $atom; $sub_domain = "($domain_ref|$domain_literal)"; $word = "($atom|$quoted_string)"; $domain = "$sub_domain(\\x2e$sub_domain)*"; $local_part = "$word(\\x2e$word)*"; $addr_spec = "$local_part\\x40$domain"; return preg_match("!^$addr_spec$!", $email) ? 1 : 0; } if (is_valid_email_address('cal@example.com')) { print 'cal@example.com is a valid e-mail address'; } else { print 'cal@example.com is not a valid e-mail address'; }
PHP中的超级变量
$_SERVER:服务器和运行环境的相关信息
$_GET:HTTP的GET请求变量
$_POST:POST变量,对于多选的Checkbox是一个数组
$_FILES:文件上传变量
$_REQUEST:一个数组,包含了GET、POST、COOKIE
$_SESSION:Session变量
$_ENV:环境变量
$_COOKIE:cookie变量
htmlentities() 与 htmlspecialchars()的区别:htmlspecialchars只转化(&’”)这5个字符,而
htmlentities将会转换所有内容
PHP多选的处理代码
The Bronx Brooklyn Manhattan Queens Staten Island <?php print 'I love ' . join(' and ', $_POST['boroughs']) . '!'; ?>

Heißer Artikel

Hot-Tools-Tags

Heißer Artikel

Heiße Artikel -Tags

Notepad++7.3.1
Einfach zu bedienender und kostenloser Code-Editor

SublimeText3 chinesische Version
Chinesische Version, sehr einfach zu bedienen

Senden Sie Studio 13.0.1
Leistungsstarke integrierte PHP-Entwicklungsumgebung

Dreamweaver CS6
Visuelle Webentwicklungstools

SublimeText3 Mac-Version
Codebearbeitungssoftware auf Gottesniveau (SublimeText3)

Heiße Themen

PHP 8.4 Installations- und Upgrade-Anleitung für Ubuntu und Debian

So richten Sie Visual Studio-Code (VS-Code) für die PHP-Entwicklung ein
