Curl Get Header - Php

How to get header information in curl using php?

Snippet Code


  
Rate this page :
  [ 0 votes]

This php code can be used to get header information using curl. Here, CURLOPT_HEADERFUNCTION method is used to fetch header information.

<?php function headerinfo( $curl, $header) { echo "</br>".$header; return strlen($header); } $ch = curl_init(); curl_setopt($ch, CURLOPT_URL,'https://www.hscripts.com'); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_HEADERFUNCTION, 'headerinfo'); $response = curl_exec($ch); ?>

Tags


Ask Questions

Ask Question