PHP.nl

Internal (built-in) functions

Internal (built-in) functions

PHP comes standard with many functions and constructs. There are also
functions that require specific PHP extensions compiled in, otherwise 
fatal "undefined function" errors will appear. For example, to use 
 functions such as 
, PHP must be compiled with
 support. Or, to use
, PHP must be compiled with
 support. There are many core functions
that are included in every version of PHP, such as the
 and 
 functions. A call 
to  or
 will show which extensions are
loaded into PHP. Also note that many extensions are enabled by default and
that the PHP manual is split up by extension. See the
,
, and individual
extension chapters, for information on how to set up PHP.

imageimagecreatetruecolor``mysqli_connectMySQListringvariablephpinfo``get_loaded_extensionsconfigurationinstallation

Reading and understanding a function's prototype is explained within the
manual section titled . It's important to realize what a function
returns or if a function works directly on a passed in value. For example,
 will return the modified string while 
 works on the actual passed in variable
itself. Each manual page also has specific information for each
function like information on function parameters, behavior changes,
return values for both success and failure, and availability information.
Knowing these important (yet often subtle) differences is crucial for
writing correct PHP code.

how to read a function definitionstr_replace``usort

Opmerking: > If the parameters given to a function are not what it expects, such as passing an where a is expected, the return value of the function is undefined. In this case it will likely return null but this is just a convention, and cannot be relied upon. As of PHP 8.0.0, a exception is supposed to be thrown in this case. array``string``TypeError

Opmerking: > Scalar types for built-in functions are nullable by default in coercive mode. As of PHP 8.1.0, passing null to an internal function parameter that is not declared nullable is discouraged and emits a deprecation notice in coercive mode to align with the behavior of user-defined functions, where scalar types need to be marked as nullable explicitly.

 For example,  function expects the parameter 
 to be a non-nullable string.
 For historical reasons, PHP allows passing null for this parameter in coercive mode, and the parameter is
 implicitly cast to , resulting in a  value.
 In contrast, a  is emitted in strict mode.
`strlen``$string``string``""``TypeError`
<?php
var_dump(strlen(null));
// "Deprecated: Passing null to parameter #1 ($string) of type string is deprecated" as of PHP 8.1.0
// int(0)

var_dump(str_contains("foobar", null));
// "Deprecated: Passing null to parameter #2 ($needle) of type string is deprecated" as of PHP 8.1.0
// bool(true)
?>
`function_exists`the function reference`get_extension_funcs``dl`