How does PHP differentiate between integer values and resource IDs when handling external resources like sockets?

PHP differentiates between integer values and resource IDs by using the functions `is_int()` and `is_resource()`. When handling external resources like sockets, it is important to check the type of the variable before performing operations on it to avoid errors.

$socket = socket_create(AF_INET, SOCK_STREAM, SOL_TCP);

if(is_resource($socket)){
    // Perform operations on the socket resource
} else {
    // Handle error or throw an exception
}