15c03-1.php

来自「介绍PHP5的给类型函数应用」· PHP 代码 · 共 46 行

PHP
46
字号
<?php// Open the file for both reading&writing access:  Using 'inifile' format.$db = dba_open('config.db3', 'c', 'inifile');// Now, if we were 'posted' to, assume an update:if (count($_POST)) {    // Save each option into the database overriding what was already there    dba_replace('fore', $_POST['fore'], $db);    dba_replace('back', $_POST['back'], $db);    dba_replace('size', $_POST['size'], $db);}// Now, in either case, read in the three config items and store them in// php variables ... default to known values if they don't exist:$fore = dba_fetch('fore', $db);if (!($fore)) { $fore = 'black'; }$back = dba_fetch('back', $db);if (!($back)) { $back = 'white'; }$size = dba_fetch('size', $db);if (!($size)) { $size = '12px'; }?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><title>Configuration</title><meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /><style>body {    color: <?= $fore ?>;    background-color: <?= $back ?>;    font-size: <?= $size ?>;}</style></head><body><form action="<?= $_SERVER['PHP_SELF'] ?>" method="post" name="myform"><p>Foreground color?  <input type="text" name="fore" value="<?= $fore ?>" /></p><p>Background color?  <input type="text" name="back" value="<?= $back ?>" /></p><p>Font size? <input type="text" name="size" value="<?= $size ?>" /></p><input value="Save Config" type="submit" /></form></body></html>

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?