class billing { function billing() { $this->form = new Form(); $this->form->AddTextBox('phone_number', 'Phone Number:', new PhoneNumValidator()); if (sizeof($_GET) == 0) { $this->form->output(); // show the form to the user } elseif (isset($_GET['validate'])) { $field = $_GET['fieldname']; $value = $_GET['value']; if ($this->form->validate($field, $value)) { echo '1'; } else { echo '0'; } echo $field; die(); } } } Class PhoneNumValidator { function validate($data) { // return true or false } }