English 中文(简体)
自动验证表单字段(服务器端)
原标题:automatic validations of form fields (server side)

最近我尝试了Zend框架(快速入门项目):) 我真的很喜欢它。

所有的框架(Zend,CakePHP)都实现了一种非常漂亮的表单字段验证方式。此外,这些验证非常容易实现,您只需要提供要应用的验证名称即可。

像这样:


        $this->addElement( text ,  email , array(
         label       =>  Your email address: ,
         required    => true,
         filters     => array( StringTrim ),
         validators  => array(
         EmailAddress ,
        )));

此外,如果任何输入与验证标准相违背并被提交,则其余表单字段值不会被清除,并显示适当的消息。

这让我想到我如何创建一个类似于这个验证标准的系统,以便它可以轻松地嵌入到没有使用框架构建的Web应用程序中。

当然,我可以用PHP来做到这一点(使用函数或类来检查每个发布的值),但我想像这些框架一样以更聪明、更有效的方式来做到这一点。

那么,有没有人知道能够进行这种验证的PHP库呢?

I hope I am able to explain my doubt clearly. Any help is greatly appreciated.

最佳回答

Why don t you just include the Zend_Form_Validation library. The idea of ZF is that you can load any libraries you want, you don t have to go through a bootstrap process to use the framework. Just include it and use it.

问题回答

HTML_QuickForm





相关问题
Brute-force/DoS prevention in PHP [closed]

I am trying to write a script to prevent brute-force login attempts in a website I m building. The logic goes something like this: User sends login information. Check if username and password is ...

please can anyone check this while loop and if condition

<?php $con=mysql_connect("localhost","mts","mts"); if(!con) { die( unable to connect . mysql_error()); } mysql_select_db("mts",$con); /* date_default_timezone_set ("Asia/Calcutta"); $date = ...

定值美元

如何确认来自正确来源的数字。

Generating a drop down list of timezones with PHP

Most sites need some way to show the dates on the site in the users preferred timezone. Below are two lists that I found and then one method using the built in PHP DateTime class in PHP 5. I need ...

Text as watermarking in PHP

I want to create text as a watermark for an image. the water mark should have the following properties front: Impact color: white opacity: 31% Font style: regular, bold Bevel and Emboss size: 30 ...

How does php cast boolean variables?

How does php cast boolean variables? I was trying to save a boolean value to an array: $result["Users"]["is_login"] = true; but when I use debug the is_login value is blank. and when I do ...

热门标签