Files
php-question/Question10-class/Ex03.php
2026-10-15 16:29:56 +09:00

42 lines
1.7 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?php
/**
* [Ex03 オブジェクト指向 クラスの活用 - POSTによるUserクラスの利用]
*
* TODO:
* 1. 既に作成した User クラス(User.php)を利用します。
* 2. require_onceを使い、User.php を読み込んでください。
* 3. 前画面からPOSTで送信された以下のデータを、それぞれ変数に格納してください。
* - ユーザID(数字):キー "user_id"
* - ユーザ名:キー "user_name"
* - メールアドレス:キー "mail"
* - パスワード:キー "password"
* 4. 変数 $us を宣言し、User クラスのインスタンスを生成して代入してください。
* 5. 取得した各値を、$us の各プロパティ(user_id, user_name, mail, password)に代入してください。
* 6. 最後に、$us の各プロパティの値を出力してください。
*
*/
// require_onceを使い、User.php を読み込んでください。
require_once __DIR__. '/User.php';
// 前画面からPOSTで送信された以下のデータを、それぞれ変数に格納
// それぞれ変数として格納
$user_id = $_POST['user_id'];
$user_name = $_POST['user_name'];
$mail = $_POST['mail'];
$password = $_POST['password'];
// 変数 $us を宣言し、User クラスのインスタンスを生成して代入してください。
$us = new User ();
// 取得した各値を、$us の
// 各プロパティ(user_id, user_name, mail, password)に代入してください。
// $usのプロパティに変数を用いて代入する
$us ->user_id = $user_id;
$us ->user_name = $user_name;
$us ->mail = $mail;
$us ->password = $password;
// 最後に、$us の各プロパティの値を出力してください。
$us ->say();