我必须开发一个表格,该表格可以记录用户年龄并计算年龄,如果超过 18 岁,则将他带到注册表格
hi i have to develop a form which takes user age and calculates age and if over 18 procedds to take him to registeration form
我的问题是我正在使用 zend 框架如何实现它,当它不应该与模型进行太多交互并且数据库中没有数据时
my question is has i am using zend framework how to implement it when its not supposed to interact with model much and their is no data in database
如何验证人的年龄
我正在尝试使用此代码
$data = array ( 'dob' => date ( "Y-m-d" ));
$select = $db
->select()
->from('data', array(
'id',
'age' => new Zend_Db_Expr("DATE_FORMAT(FROM_DAYS(TO_DAYS(NOW())-TO_DAYS(dob)), '%Y')+0")))
我可以使用数组吗?请帮我朋友秀应该是这个查询
can i use an array ? please help me friendshow should be this query
我不太明白您的问题...您是否在根据出生日期计算年龄时遇到问题?
I don't quite understand your question... Are you having trouble calculating the age from a DOB?
如果是这样,这应该可以解决您的问题:
If so, this should take care of your problem:
function Age($date = 'now')
{
return intval(substr(date('Ymd') - date('Ymd', strtotime($date)), 0, -4));
}
var_dump(Age('1975-04-25')); // int(36)
if (Age('1975-04-25') >= 18)
{
// proceed to registration
}
这篇关于在注册用户之前验证年龄以使用 mvc 检查他是否超过特定年龄的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!
Zend 中的动作视图助手 - 解决方法?Action View Helper in Zend - Work around?(Zend 中的动作视图助手 - 解决方法?)
这是将 URI 与 PHP 中用于 MVC 的类/方法匹配的好方Is this a good way to match URI to class/method in PHP for MVC(这是将 URI 与 PHP 中用于 MVC 的类/方法匹配的好方法吗)
我在哪里保存 Zend Framework 中的部分(视图),以便Where do I save partial (views) in Zend Framework, to be accessible for all Views in my App?(我在哪里保存 Zend Framework 中的部分(视图),以
有一个网站的单一入口点.坏的?好的?没问题?Having a single entry point to a website. Bad? Good? Non-issue?(有一个网站的单一入口点.坏的?好的?没问题?)
MVC + 服务层在 Zend 或 PHP 中常见吗?Is MVC + Service Layer common in zend or PHP?(MVC + 服务层在 Zend 或 PHP 中常见吗?)
PHP MVC 方法中的 Hello World 示例Hello World example in MVC approach to PHP(PHP MVC 方法中的 Hello World 示例)