Wednesday, April 3, 2013

OOP -> Type Hinting


PHP5 Introduce Type Hinting, that force the method/function parameter to specific type.

Suppose you have create an function that reverse the array, and you want whenever some call your function must pass the array parameter.

In this case, type hinting will help you.

Following are the example of type hinting
function reverse(array $array ){
  rsort($array);
  return $array;  
}
$array = Array('zend','framework','200','500');
reverse($array);

No comments:

Post a Comment