Aaron Yodaiken
Aaron Yodaiken

Reputation: 19561

get the requested version of http from response in PHP

I'd like to be able to determine whether my PHP script was called from HTTP 1.0 or HTTP 1.1 (or maybe some newer version if one ever comes out).

As in, the following code:

<?php
    $ver = /*???*/;
    echo 'You requested me with HTTP ' . $ver;

should echo out You requested me with HTTP 1.0 or You requested me with HTTP 1.1.

What is the fastest way to do this?


(Yes, I know this a bit silly---most things these days are HTTP 1.1, but I worry about that one curl client.)

Upvotes: 2

Views: 97

Answers (2)

Lior Cohen
Lior Cohen

Reputation: 9055

<?php
  echo $_SERVER['SERVER_PROTOCOL'];
?>

Upvotes: 0

user652649
user652649

Reputation:

try

echo $_SERVER['SERVER_PROTOCOL'];

Upvotes: 1

Related Questions