Google News
logo
PHP - Interview Questions
Explain Type hinting in PHP?
In PHP Type hinting is used to specify the excepted data type of functions argument. Type hinting is introduced in PHP 5.
 
Example usage :
 
//send Email function argument $email Type hinted of Email Class. It means to call this function you must have to pass an email object otherwise an error is generated.
 
<?php
function sendEmail (Email $email)
{
  $email->send();
}
?>
Advertisement