Advanced PHP
June 3, 2026 1 min read

PHP Type Hinting for Function Argument Data Types

HS
HEMANT SINGH
Technical Writer & Educator

Type hinting or type declaration allows to declare data type of argument in function definition, so that function can accept same type of data on it, otherwise it will through the fatal error.

Example

function sum(int $x, int $y){
	echo $x+$y;
}
sum(10, 20);
sum ("1","2");