12c01-2.php
来自「介绍PHP5的给类型函数应用」· PHP 代码 · 共 24 行
PHP
24 行
<?php// This script has two functions, either ask for data, or display data.// Check if we have both variables we care about:if (isset($_REQUEST['firstname']) && isset($_REQUEST['zipcode'])) { // Update or create the cookies, all set to expire in 1 hour: setcookie('firstname', $_REQUEST['firstname'], time()+3600); setcookie('zipcode', $_REQUEST['zipcode'], time()+3600); // Now, also, just print the standard output: echo "<p>Welcome back {$_REQUEST['firstname']}! Perhaps you would like to see things happening near your home zipcode ({$_REQUEST['zipcode']}) ?</p>";} else { // We have nothing, so make a form so they can provide data. echo "<form action=\"{$_SERVER['PHP_SELF']}\" method=\"POST\"><p>What is your first name? <input type=\"text\" name=\"firstname\" /></p><p>What is your zipcode? <input type=\"text\" name=\"zipcode\" /></p><p><input type=\"submit\" /></p></form>";}?>
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?