I'm a new to coding, and I'm having some trouble understanding a script that sets the new object's properties. Please help me. Thank you in advance.
First, in sign_up.php, I have a input element with POST method as such...
<?php include_once('classes/signup.class.php'); ?>
...
<input type="text" class="input-xlarge" id="name" name="name"
value="<?php echo $signUp- >getPost('name'); ?>" placeholder="<?php _e('Full name'); ?>">
In the signup.class.php, I have the following code...
class SignUp
function __construct() {
if(!empty($_POST)) {
foreach ($_POST as $field => $value)
$this->settings[$field] = $value;
$this->process();}
public function getPost($var) {
return empty($this->settings[$var]) ? '' : $this->settings[$var];}
}
$signUp = new SignUp();
To my understanding, the getPost($var) will return empty until the form is submitted. Once it is submitted, __constructor() will execute the foreach loop and for the second time, $value will call to parse getPost('name'). This time around, what is $this->settings[$var]?
I am confused, and any of your help will be much appreciated.