Sie sind auf Seite 1von 2

Zend_Filters

Zend_Filters l mt lp c chc nng lc d liu trc khi thc hin mt qu trnh x l no .

1. Loi b nhng k t khng phi l alphabetic v number (Zend_Filter_Alnum)


$str = 'asdasd \#$%@&*!)(&^^%#123jasd'; $filter = new Zend_Filter_Alnum(true); echo $filter->filter($str);// $str = 'asdasd 123jasd';

$filter = newZend_Filter_Alnum(true) : ng c k t khong trng $filter = newZend_Filter_Alnum() : khng c k t khong trng 2. Loi b nhng k t khng phi l alphabetic (Zend_Filter_Alpha)
$str = 'asdasd \#$%@&*!)(&^^%#123jasd'; $filter = new Zend_Filter_Alpha(true); echo $filter->filter($str);

$filter = newZend_Filter_Alpha(true) : ng c k t khong trng $filter = newZend_Filter_Alpha() : khng c k t khong trng 3. Ly tn tp tin t mt ng dn (Zend_Filter_BaseName)
$str = 'http://framework.zend.com/manual/en/zend.filter.set.html'; $alpha = new Zend_Filter_BaseName(); echo $alpha->filter($str);

4. o ngc mt chui (Zend_Filter_Callback('strrev'))


$str = 'Hello'; $alpha = new Zend_Filter_Callback('strrev'); echo $alpha->filter($str);

5. Loi b nhng k t khng phi l s nguyn (Zend_Filter_Digits)


$str = '0123.12'; $alpha = new Zend_Filter_Digits(); echo $alpha->filter($str);

6. Ly ng dn th mc (Zend_Filter_Dir)
$str = 'http://framework.zend.com/manual/en/zend.filter.set.html'; $alpha = new Zend_Filter_Dir(); echo $alpha->filter($str);

7. Chuyn i chui thnh ch thng

$str = 'HAPPY birthday'; $alpha = new Zend_Filter_StringToLower(); echo $alpha->filter($str);

8. Chuyn i thnh ch hoa


$str = 'HAPPY birthday'; $alpha = new Zend_Filter_StringToUpper(); echo $alpha->filter($str);

9. Loi b khong trng u chui v cui chui


$str = 'HAPPY birthday'; $alpha = new Zend_Filter_StringTrim(); echo $alpha->filter($str);

10. Multi Filter - Khi chng ta cn lc nhiu iu kin cho mt tham s truyn. Chng ta s dng cc multi filter
$filterChain = new Zend_Filter(); $filterChain->addFilter(new Zend_Filter_Alpha()) ->addFilter(new Zend_Filter_StringToLower()); // Filter the username $username = $filterChain->filter($_POST['username']);

11. Cch t tn Action trong Controller Tn Action

public function parentRowAction() { echo 'This is parentRowAction()'; }

Tn cho View

parent-row.phtml

Truy cp URL: <modules>/<controller>/parent-row/

Das könnte Ihnen auch gefallen