0
이 오류는 특정 요소 하나에 나타납니다. 다른 모든 요소는 이러한 인덱스를 얻을 수 있지만이 인덱스는 얻을 수 없습니다. 그것은 이전에 효과가 있었지만 지금은 완전히 파손되었습니다. 나는 약간의 변화를 원상태로 돌리려고했지만 정말로 도움이되지 않았고 나는 이것이 왜 실제로 일어나는 지 궁금해하고있다. http://i.imgur.com/FIkHJop.png 을 그리고 코드 : 당신은 단순히 페이지를 새로 고침하여 테스트 할 때특정 요소에서 "정의되지 않은 인덱스"오류
<?php
class User {
public function __construct($username, $password, $passwordRepeat, $email, $firstName, $familyName, $age, $sex, $question, $answer, $car) {
$this->username = $username;
$this->password = $password;
$this->passwordRepeat = $passwordRepeat;
$this->email = $email;
$this->firstName = $firstName;
$this->familyName = $familyName;
$this->age = $age;
$this->sex = $sex;
$this->question = $question;
$this->answer = $answer;
$this->car = $car;
}
public function savePicture($profilePicture) {
/*do this later*/
}
public function saveUser() {
$profiles = "profiles/$this->username.txt";
if ($this->password !== $this->passwordRepeat) {
require "register.html";
echo "<p><strong>Passwords do not match! Please try again</strong></p>";
} else if (file_exists($profiles)) {
require "register.html";
echo "<p><strong>Username already exists!</strong></p>";
} else {
$fp = fopen($profiles, "a+");
$save = $this->username . " , " . $this->password . " , " . $this->email . " , " . $this->firstName . " , " . $this->familyName . " , " . $this->age . " , " . $this->sex . " , " . $this->question . " , " . $this->answer . " , " . $this->car;
fwrite($fp, $save);
}
}
public function printUser() {
echo $this->username . " , " . $this->password . " , " . $this->email . " , " . $this->firstName . " , " . $this->familyName . " , " . $this->age . " , " . $this->sex . " , " . $this->question . " , " . $this->answer . " , " . $this->car;
}
}
/*This is the problematic element. It worked before but then it broke for some reason. PHPStorm doesn't say anything*/
$user = new User($_POST['username_register'], $_POST['password_register'], $_POST['password_repeat'], $_POST['email_register'], $_POST ['first_name_register'], $_POST ['last_name_register'], $_POST['age'], $_POST ['sex_register'], $_POST ['question_register'], $_POST ['answer_register'], $_POST['car']);
/*----------------------*/
$user->saveUser();
$user->printUser();
슬프게도 작동하지 않았습니다. – Milenchy