Are PHP predefined functions written in PHP or another language?

PHP predefined functions are written in C, not PHP. These functions are compiled into the PHP interpreter and are readily available for use in PHP scripts. If you need to create a custom function that mimics the behavior of a PHP predefined function, you can write it in PHP.

// Example of creating a custom function in PHP
function custom_strlen($string) {
    $length = 0;
    for ($i = 0; isset($string[$i]); $i++) {
        $length++;
    }
    return $length;
}

// Using the custom function
$string = "Hello, World!";
echo custom_strlen($string); // Output: 13