本文介紹了在注冊用戶之前驗證年齡以使用 mvc 檢查他是否超過特定年齡的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!
問題描述
我必須開發一個表格,該表格可以記錄用戶年齡并計算年齡,如果超過 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模板網!
【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!