★twigのimportとincludeはどこが違うの? (6レス)
上
下
前
次
1-
新
6
: 07/10(水)20:37
ID:G1nCEzbNC(6/6)
AA×
[240|
320
|
480
|
600
|
100%
|
JPG
|
べ
|
レス栞
|
レス消
]
6: [] 2024/07/10(水) 20:37:35.04 ID:G1nCEzbNC {% set max_attempts = 3 %}<!DOCTYPE html><html lang="en"><head><meta charset="UTF-8"> <title>Escape Game</title></head><body><h1>Escape Game</h1><p>Guess the secret number between 1 and 10!</p> {# {{secret_number}} #}{% block content %}{% set attempts = attempts + 1 %}{% if attempts > max_attempts %} <p>Sorry, you failed to guess the number within {{ max_attempts }} attempts.</p> <p>The secret number was {{ secret_number }}.</p>{% endif %} <form action="?attempts={{attempts}}&secret_number={{secret_number}}" method="post"> <label for="guess">Enter your guess (1-10):</label> <input type="number" id="guess" name="guess" min="1" max="10" required> <button type="submit">Guess</button></form>{% if guess == secret_number %} <p>Congratulations! You guessed the secret number {{ secret_number }}!</p>{% else %} <p>Sorry, that's not the correct number. Try again!</p>{% endif %} {% endblock %}</body></html> <?php require_once 'vendor/autoload.php'; $loader = new \Twig\Loader\FilesystemLoader(__DIR__); $twig = new \Twig\Environment($loader); if ($_SERVER['REQUEST_METHOD'] === 'POST') {$guess = $_POST['guess'];}else{$guess = 0;} if (isset($_GET['attempts'])) {$attempts = $_GET['attempts'];}else{$attempts = 0;} if (isset($_GET['secret_number'])) {$secret_number = $_GET['secret_number']; }else{$secret_number = rand(1,10);} echo $twig->render('escape_while.twig', ['guess' => $guess,'attempts' => $attempts,'secret_number' => $secret_number]); ?> http://toro.2ch.sc/test/read.cgi/tech/1720605115/6
上
下
前
次
1-
新
書
関
写
板
覧
索
設
栞
歴
スレ情報
赤レス抽出
画像レス抽出
歴の未読スレ
AAサムネイル
ぬこの手
ぬこTOP
0.041s