PHP Functions
PHP functions are blocks of reusable code that perform specific tasks. Functions in PHP can be built-in (like strlen()
, array_merge()
, etc.) or user-defined.
Syntax for a User-Defined Function
Example
Common Built-In PHP Functions
Category | Function Examples |
---|---|
String | strlen() , str_replace() , strpos() , substr() |
Array | array_push() , array_merge() , in_array() |
Math | abs() , round() , rand() , max() |
Date/Time | date() , time() , strtotime() |
File Handling | fopen() , fwrite() , fread() , fclose() |
Variable | isset() , empty() , unset() |