Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
1
10php
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Yu Kimiduka
10php
Commits
ee0566dd
Commit
ee0566dd
authored
Jul 07, 2016
by
君塚 悠
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
プログラム作成(game.php:数当て)
parent
f45d2293
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
39 additions
and
0 deletions
+39
-0
game.php
php/php10/day03-2/game.php
+39
-0
No files found.
php/php10/day03-2/game.php
0 → 100644
View file @
ee0566dd
session_start();
<html>
<head>
<title>
数当てゲーム
</title>
</head>
</html>
<body>
<h1
style=
"background: #cccccc#>数当てゲーム</h1>
<form method="
POST
"
action=
"game.php"
>
1~100までの中からいずれかの数を入力してください:
<input
type=
"text"
name=
"answer"
size=
"5"
maxlength=
"3"
/>
<input
type=
"submit"
value=
"回答"
/>
</form>
<hr
/>
<?php
session_start
();
if
(
is_null
(
$_SESSION
[
'answer'
]))
{
mt_srand
(
microtime
()
*
1000000
);
$_SESSION
[
'answer'
]
=
mr_rand
(
1
,
100
);
$_SESSION
[
'game_cnt'
]
=
0
;
}
if
(
$_POST
[
'answer'
]
!=
""
)
{
$_SESSION
[
'game_cnt'
]
++
;
if
(
$_SESSION
[
'answer'
]
==
$_POST
[
'answer'
])
{
print
(
"おめでとうございます!"
.
$_SESSION
[
'game_cnt'
]
.
"回で正解しました!"
);
session_sestroy
();
}
else
{
if
(
$_SESSION
[
'answer'
]
>
$POST
[
'answer'
])
{
print
(
"もうすこし大きいです。"
);
}
else
{
print
(
"もうすこし小さいです。"
);
}
}
}
?>
</body>
</html>
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment