我正在尝试检查验证。在PrestaShop我这样做:
# The Replace Class
class Replace
def replace_letter( string_to_replace )
puts string_to_replace.tr('e', '3')
end
end
# Create a new object
main = Replace.new()
# Output String after replace
main.replace_letter('elijah')
有没有人知道如何在OpenCart中执行此操作?
由于
答案 0 :(得分:0)
打开此文件,例如:
catalog/controller/information/contact.php
您会看到validate function
:
protected function validate() {
if ((utf8_strlen($this->request->post['name']) < 3) || (utf8_strlen($this->request->post['name']) > 32)) {
$this->error['name'] = $this->language->get('error_name');
}
if (!filter_var($this->request->post['email'], FILTER_VALIDATE_EMAIL)) {
$this->error['email'] = $this->language->get('error_email');
}
if ((utf8_strlen($this->request->post['enquiry']) < 10) || (utf8_strlen($this->request->post['enquiry']) > 3000)) {
$this->error['enquiry'] = $this->language->get('error_enquiry');
}
// Captcha
if ($this->config->get($this->config->get('config_captcha') . '_status') && in_array('contact', (array)$this->config->get('config_captcha_page'))) {
$captcha = $this->load->controller('extension/captcha/' . $this->config->get('config_captcha') . '/validate');
if ($captcha) {
$this->error['captcha'] = $captcha;
}
}
return !$this->error;
}
在该文件中,您还可以看到如何使用此功能:
if (($this->request->server['REQUEST_METHOD'] == 'POST') && $this->validate()) {