Skip to content
PHP Logo

What are common reasons for the error "Call to undefined function: socket_create()" in PHP scripts?

The error "Call to undefined function: socket_create()" in PHP scripts occurs when the socket extension is not enabled in the PHP configuration. To solve this issue, you need to enable the socket extension in your php.ini file or install the PHP socket extension if it is not already installed.

php
// Check if the socket extension is enabled
if (!function_exists('socket_create')) {
    die('Socket extension is not enabled. Please enable the socket extension in your PHP configuration.');
}

// Your PHP code that uses socket_create() function