строка кодов в php

Ниже приведен код … помогите мне понять нижеследующие коды строки …

if (isset($_POST['register'])) { $error = array(); if (!in_array(strtolower($_POST['captcha']), $aCaptcha[$_SESSION['captcha']])) { $error['captcha'] = "<span style='color:red'>The name of the animal is not correct.</span>"; } if (count($error) == 0) { //no errors, do other actions here, like saving into database, send email or... echo "<span style='color:red'>Thank you for completing the form. We shall contact you soon.</span>"; die(); 

 if (isset($_POST['register'])) { 

Выполняйте только следующее, если register параметров был передан как переменная POST

  $error = array(); 

Объявить пустой массив $error

  if (!in_array(strtolower($_POST['captcha']), $aCaptcha[$_SESSION['captcha']])) { $error['captcha'] = "<span style='color:red'>The name of the animal is not correct.</span>"; } 

Если представленный CAPTCHA не находится в массиве, который содержит список допустимых CAPTCHAS, добавляет ошибку в массив $error

  if (count($error) == 0) { //no errors, do other actions here, like saving into database, send email or... echo "<span style='color:red'>Thank you for completing the form. We shall contact you soon.</span>"; die(); 

Если ошибок нет, распечатайте сообщение об успешном завершении и выйдите из сценария.

 if the `register` variable exists in the post array (meaning the form was POSTed) declare an empty array and assign it to the error variable if the converted-to-lowercase posted value of the captcha is not the same as the captcha for this session from the aCaptcha array populate the error array with a message letting the user know that what they typed is wrong. if the error array is empty //no errors, do other actions here, like saving into database, send email print a success message exit the script. 

Я только заметил, что на самом деле это репозиция более длинного вопроса, который вы задали при изображении captcha в php

этот код – всего лишь небольшой фрагмент.

но похоже, что это код для реализации Captcha http://en.wikipedia.org/wiki/CAPTCHA

поэтому человек пытается зарегистрироваться, отправляет имя животного, которое он видит, и эта часть кода проверяется в основном, если введенное имя животного введено правильно. для этого он игнорирует, если буква большая или маленькая. если captcha был прав, чем показывает, что регистрация в порядке. если нет, то это показывает ошибки.

кажется, что он показывает картину животного на одной странице, а затем вы должны ввести имя животного. форма отправляет введенное имя через POST в переменной captcha. В сеансе сервер сохранил изображение, которое было показано ($ _SESSION ['captcha'])

$ aCaptcha, похоже, представляет собой массив всех животных.

 /* * checks if the POST variable 'register' is set */ if (isset($_POST['register'])) { /* * create an empty array called $error */ $error = array(); /* * Converts the POST variable 'captcha' to lowercase then * checks if the POST variable 'captcha' is not in the $aCaptcha array. * If it is not in the array it adds the error message to the $error array with key 'captcha'. */ if (!in_array(strtolower($_POST['captcha']), $aCaptcha[$_SESSION['captcha']])) { $error['captcha'] = "<span style='color:red'>The name of the animal is not correct.</span>"; } /* * If the $error array is empty then there are no errors so display a thank you message */ if (count($error) == 0) { //no errors, do other actions here, like saving into database, send email or... echo "<span style='color:red'>Thank you for completing the form. We shall contact you soon.</span>"; } /* * Stops any more script execution. */ die(); } /* * There were a couple of missing closing tags there, * im not sure if that was intentional by you or not * but I have added them. */