Basic question with respect to Drupal form API I am learning the Drupal Form API. I am new to HTML and PHP also.
I read in a book how to define a form in Drupal, where they used the following example:

/**
* Define a form.
*/
function formexample_nameform() {
  $form['user_name'] = array(
    '#title' =&gt; t('Your Name'),
    '#type' =&gt; 'textfield',
    '#description' =&gt; t('Please enter your name.'),
  );
}


What will the HTML equivalent of above example be?
Similarly, to validate the form they did it as follows:

/**
 * Validate the form.
 */
function formexample_nameform_validate($form, &amp;$form_state) {
  if ($form_state['values']['user_name'] == 'King Kong') {
    // We notify the form API that this field has failed validation.
    form_set_error('user_name',t('King Kong is not allowed to use this form.'));
  }
}


What will be HTML equivalent of both of these functions?
The HTML produced from the first function (the form builder) can be roughly seen checking the code for the theme functions, which are at least two: theme_textfield(), and theme_form(). The exact output can change basing on the theme being used, and third-party modules installed on the site.

For the validation handler, the function that adds the class for form fields with a validation error is _form_set_error(), while the list of the validation error messages are set with form_set_error(), which uses the following snippet:

  if ($message) {
    drupal_set_message($message, 'error');
  }


The messages that are set with drupal_set_message() are then output with theme_status_messages().

Also in this case, the real output depends from the theme being used, and from other modules installed on the Drupal site; both can alter the output used for the rendering.