$options = array(
CURLOPT_URL => 'http://www.example.com/',
CURLOPT_RETURNTRANSFER => true, // boolean
CURLOPT_HEADER => false, // boolean
CURLOPT_USERAGENT => '' // empty string, will be filtered
);
// Filter only non-empty strings
$options = array_filter($options, fn($v) => gettype($v) === 'string' && strlen($v) > 0);
$ch = curl_init();
foreach($options as $opt => $val){
curl_setopt($ch, $opt, $val);
}
$response = curl_exec($ch);
curl_close($ch);
No hay comentarios:
Publicar un comentario