实例
<?php $data = ['a','b','c','d','e','f']; ?> <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>foreach</title> </head> <body> <ul> <?php foreach ($data as $key=>$value){?> <li><?php echo ($key+1).':'.$value ?></li> <?php } ?> </ul> <hr> <ul> <?php foreach ($data as $v):?> <li><?php echo $v ?></li> <?php endforeach ?> </ul> </body> </html>
运行实例 »
点击 "运行实例" 按钮查看在线实例
实例
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>get</title> </head> <body> <form action="" method="get" > <label for="email">邮箱:</label> <input type="email" name="email" id="email" value="<?php echo isset($_GET['email']) ? $_GET['email'] : ''; ?>"> <label for="password">密码:</label> <input type="password" name="password" id="password" value="<?php echo isset($_GET['password']) ? $_GET['password'] : ''; ?>"> <button>登录</button> </form> <?php echo '<pre>'; print_r($_GET); ?> </body> </html>
运行实例 »
点击 "运行实例" 按钮查看在线实例
实例
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>post</title> </head> <body> <form action="" method="post" > <label for="email">邮箱:</label> <input type="email" name="email" id="email" value="<?php echo isset($_POST['email']) ? $_POST['email'] : ''; ?>"> <label for="password">密码:</label> <input type="password" name="password" id="password" value="<?php echo isset($_POST['password']) ? $_POST['password'] : ''; ?>"> <button>登录</button> </form> <?php echo '<pre>'; print_r($_POST); ?> </body> </html>
运行实例 »
点击 "运行实例" 按钮查看在线实例