I use the following code to check the file size of a external pdf. But I want to add a timeout and skip if the external server does not respond within 1 second. How can I achieve this?
My current code:
<?php
$newmanual = "https://www.example.com/file.pdf"
$head = array_change_key_case(get_headers($newmanual, TRUE));
$filesize = $head['content-length'];?>
Curl has a timeout function, you could use that to get the headers.
Code taken from posts how to set curl timeout and get header from php curl