原帖由 母鸡 于 2011-8-28 01:19 发表
菊花君 如果学c++ php啥的能不学自会???
只能说学了任何一门语言,会对编程有新的理解,以前你们的理解我不清楚是怎么样的。
当然你学过任何一门语言,都会使你学习下一门语言轻松很多。贴一段最基本的判断PHP的给你,我没学过PHP,也没看手册,只是根据别人的代码修改。
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>统计</title>
<style type="text/css">
div {
text-align:right;
}
</style>
</head>
<body>
<div>
<form method="post">
命令:
<input name="del" type="text" />
<input type="submit" value="确认" />
<a href="?">停止刷新</a> | <a href="?result">查看结果</a>
</form>
</div>
<?php
function writeFile($filename, $content, $mode = 'a+') {
$fp = fopen($filename, $mode);
fwrite($fp, $content);
fclose($fp);
}
$filename = $_GET['filename'] ? $_GET['filename'] : 'vote.tmp.php';
$status = TRUE;
if (!file_exists($filename)) writeFile($filename, '<?php'."\n", 'w+');
include_once($filename);
if ($status && $_POST['vote']) writeFile($filename, '$vote[\''.$_POST['vote'].'\'] = '.(++$vote[$_POST['vote']]).';'."\n");
if (isset($_GET['result'])) {
if ($status == 'TRUE'){
echo '以下为统计为实时显示,页面3秒自动刷新一次<br>';
echo '最后一次刷新:';
echo date("Y-m-d H:i:s ");
echo '<hr>';
echo '<meta http-equiv=refresh content="3">';
} else {
echo '<font color="red">投票不再更新,已被工作人员停止,</font>页面10秒自动刷新一次<hr>';
echo '<meta http-equiv=refresh content="10">';
}
if (sizeof($vote)) {
echo '<p><font color="red">票项</font> << ====== >> <font color="red">票数</font></p>';
foreach ($vote as $k => $v) {
echo '<b>'.$k.'</b> << ====== >> <b><font color="blue">'.$v.'票</font></b><hr>';
}
} else {
echo '没有数据';
}
}
if (isset($_POST['del'])) {
if ($_POST['del'] == 'close') {
writeFile($filename, '$status = FALSE;'."\n");
echo "<script>alert('投票已关闭')</script>";
} elseif ($_POST['del'] == 'open') {
writeFile($filename, '$status = TRUE;'."\n");
echo "<script>alert('投票已成功打开')</script>";
}
if ($_POST['del'] == '@delsjzy') {
$result = @unlink ($filename);
echo "<script>alert('删除成功')</script>";
} else {
echo "<script>alert('error')</script>";
}
}
?>
</body>
</html> |