2

like the title states I'm running the same script on two different PHP versions.

  • My Server 1- 5.2.17
  • My Server 2- 5.3.19

get_headers($url, 1);
$url was google (no www) with http and .co.uk - Or use any url that returns a 404 An example of the different outputs are:

My Server 1-

  • [Server] => gws [gathered from the header]

My Server 2-

  • [Server] => Array [gathered from the header]

    (
        [0] => gws
        [1] => gws
    )
    

What I presume is that Server 2 is following the location of a 301 and adding that to the header, where Server 1 only has the 301 header in the array.

So Server 2 would go to "http://google.co.uk" (this returns 301); and then follows it to "http://www.google.co.uk/" and adds both responses to the same output.

What my question is- what causes the change? I've checked over the PHP channel log and I can't see a mention to get_headers so I must be missing something.

If you know what causes the different outputs, and even better know how I can revert the change (without changing back to the old PHP version) I'd greatly appreciate it. I know I could use cURL but I wouldn't really want to do that.

Full-ish code (without validation etc.)

1.$address = ($_POST['address']);
2.$headerinfo = get_headers($url, 1);
$server = $headerinfo[Server]; 
  • In PHP 5.2 - if I echo $server it would be something like "Apache".

  • In PHP 5.3 - If I echo $server it would be "Array" (if it hits a 301).

In the end I'm planning on storing the $sever in a DB. I can't/don't want "Array" stored there.

Thanks.

A.B
  • 21
  • 2
  • Try eliminating some variables — try running the same version on both servers, for instance, to see if it's a variation between PHP versions or servers. – icktoofay Feb 05 '13 at 01:45
  • I don't fully understand - could you expand a little please?. I believe I may have done this already. One (local) sever was running PHP version 5.2 and another (local) Server was running 5.3 - With the same input they had different outputs. – A.B Feb 05 '13 at 01:52
  • 1
    If I understood you correctly, you have two servers. One server runs one version of PHP and the other server runs another. If you run the same version of PHP on both servers and the output is the same, the difference is caused by PHP. Otherwise, it is because of something else. – icktoofay Feb 05 '13 at 01:54
  • Ah thats a very good idea I'll check it out in a moment when when I found out the correct method using .htaccess. One moment – A.B Feb 05 '13 at 01:57
  • I attempted to use .htaccess to change the PHP to 5.2 using: AddHandler application/x-httpd-php52 .php .php5 .php4 .php3 However this just causes the page to be downloaded when I navigate to it ?. Any ideas?. – A.B Feb 05 '13 at 02:04
  • Just adding `AddHandler` will do nothing useful if the version is not installed. You'll have to install it if it isn't installed. I'd recommend doing this through the CLI version of PHP so you don't have to mess too much with Apache's configuration. – icktoofay Feb 05 '13 at 02:12

0 Answers0