회원 로그인
|
클래스
PHP 클래스
:로그인 (ID/패스워드)
class1.php
class2.php
class3.php
:로그인 (ID/패스워드)
class1.php
<?php // 기본 클래스 선언 및 객체 생성 // 클래스 선언 // class 클래스명 class GameUser { // 멤버 변수 선언 var $id = "user"; var $pw = "0000"; // 메소드 선언 // 유저 정보 설정 function RequestUserInfo() { $id = $_POST["user_id"]; $pw = $_POST["user_pw"]; // $this->id = $id; $this->pw = $pw; } // 유저 정보 보기 function ResponseUserInfo() { // 결과 딕셔너리 생성 $response_data = array( "id" => $this->id, "pw" => $this->pw ); //배열을 json으로 인코딩해서 응답함 echo json_encode($response_data); } } // php 객체 생성 $user = new GameUser(); // 유저 정보 요청 받음 $user->RequestUserInfo(); // 유저 정보 응답 해줌 $user->ResponseUserInfo(); ?>
class2.php
<?php // php 상속 예제 // 클래스 선언 // class 클래스명 class User { // 멤버 변수 선언 var $id = "user"; var $pw = "0000"; // 메소드 선언 // 유저 정보 설정 function RequestUserInfo() { $id = $_POST["user_id"]; $pw = $_POST["user_pw"]; $this--->id = $id; $this->pw = $pw; } // 유저 정보 보기 function ResponseUserInfo() { // 결과 딕셔너리 생성 $response_data = array( "id" => $this->id, "pw" => $this->pw ); // 배열을 json으로 인코딩해서 응답함 echo json_encode($response_data); } } // User 클래스를 상속함 GameUser 클래스를 선언함 class GameUser extends User { // 자식 클래스 멤버 추가 var $playTime = "0"; // 자식 클래스 메소드 추가 function RequestGameUserInfo() { // parent 키워드를 통해 부모 메소드를 호출 parent::RequestUserInfo(); // 자식 멤버 변수값 설정 $this->playTime = $_POST["play_time"]; } // 부모 메소드를 오버라이드 함 function ResponseUserInfo() { // 결과 딕셔너리 생성 $response_data = array( "id" => $this->id, "pw" => $this->pw, "playTime" => $this->playTime ); // 배열을 json으로 인코딩해서 응답함 echo json_encode($response_data); } } // PHP 객체 생성 $user = new GameUser(); // 게임 유저 정보 요청 받음 $user->RequestGameUserInfo(); // 게임 유저 정보 응답 해줌 $user->ResponseUserInfo(); ?>
class3.php
<?php // 생성자 사용 // 클래스 선언 // class 클래스명 class User { // 멤버 변수 선언 var $id = "user"; var $pw = "0000"; // 생성자 function __construct($id, $pw) { $this--->id = $id; $this->pw = $pw; } // 유저 정보 보기 function ResponseUserInfo() { // 결과 딕셔너리 생성 $response_data = array( "id" => $this->id, "pw" => $this->pw ); // 배열을 json으로 인코딩해서 응답함 echo json_encode($response_data); } } // User 클래스를 상속함 GameUser 클래스를 선언함 class GameUser extends User { // 자식 클래스 멤버 추가 var $playTime = "0"; // GameUser 클래스의 생성자 (__construct) function __construct($id, $pw, $playTime) { // 부모 생성자를 호출함 parent::__construct($id, $pw); $this->playTime = $playTime; } // function __desctruct() { ... } 소멸자 // 부모 메소드를 오버라이드 함 function ResponseUserInfo() { // 결과 딕셔너리 생성 $response_data = array( "id" => $this->id, "pw" => $this->pw, "playTime" => $this->playTime ); // 배열을 json으로 인코딩해서 응답함 echo json_encode($response_data); } } $id = $_POST["user_id"]; $pw = $_POST["user_pw"]; $playTime = $_POST["play_time"]; // $user = new User($id, $pw); // PHP 객체의 생성자 호출 및 객체 생성 $user = new GameUser($id, $pw, $playTime); // 게임 유저 정보 응답 해줌 $user->ResponseUserInfo(); ?>
댓글 0개
| 엮인글 0개
285개(1/15페이지)
번호 | 제목 | 글쓴이 | 조회 | 날짜 |
---|---|---|---|---|
285 | [Python] 동적 import - 모듈을 변수로 받아오기 | 푸딩뱃살 | 413 | 2022.10.27 10:45 |
284 | [Python] 파이썬 3.7.7과 3.9.7의 os.path.expanduser() 차이 | 푸딩뱃살 | 456 | 2022.08.18 12:22 |
283 | [Python] error: Microsoft Visual C++ 9.0 is required. | 푸딩뱃살 | 684 | 2022.08.03 13:35 |
282 | [Python] pyscript | 푸딩뱃살 | 454 | 2022.06.09 11:21 |
281 | [Python] float is / float not is | 푸딩뱃살 | 593 | 2022.03.02 15:03 |
280 | [Python] 이터널 문자열 f | 푸딩뱃살 | 833 | 2022.01.27 16:35 |
279 | [Python] is와 ==의 차이 | 푸딩뱃살 | 485 | 2021.11.25 15:54 |
278 |
[Python] Error: ImportError: file |
푸딩뱃살 | 916 | 2021.11.16 11:24 |
277 | [Python] 파이썬 디컴파일 - uncompyle6 | 푸딩뱃살 | 774 | 2021.11.10 14:46 |
276 | [Python] 파이썬 확장자 설명 | 푸딩뱃살 | 550 | 2021.11.03 14:38 |
275 | [참고] 웹 fbx 뷰어 | 푸딩뱃살 | 470 | 2021.10.19 15:46 |
274 | [Python] enumerate() | 푸딩뱃살 | 500 | 2021.10.13 14:44 |
273 | [Python] 아나콘다에서 가상 환경 | 푸딩뱃살 | 720 | 2020.11.21 00:26 |
272 | [Python] pip로 설치 때 퍼미션 에러 | 푸딩뱃살 | 1266 | 2020.06.06 17:13 |
271 | [Python] OpenCV 10-3. 이미지 Thresholding - Otsu's Binarizatio | 푸딩뱃살 | 674 | 2020.06.05 14:01 |
270 | [Python] OpenCV 10-2. 이미지 Thresholding - Adaptive Threshold | 푸딩뱃살 | 694 | 2020.06.05 13:58 |
269 | [Python] OpenCV 10-1. 이미지 Thresholding | 푸딩뱃살 | 578 | 2020.06.05 13:56 |
268 | [Python] OpenCV 9-2. 색 추적 | 푸딩뱃살 | 772 | 2020.06.02 23:29 |
267 | [Python] OpenCV 9-1. 색공간 바꾸기 | 푸딩뱃살 | 640 | 2020.06.02 23:27 |
266 | [Python] OpenCV 8-3. 이미지 비트 연산 | 푸딩뱃살 | 530 | 2020.06.02 23:21 |