0

I run this code:

<?php
     $test = $_SERVER['HTTP_HOST'];
     var_dump($test);
     print_r($test);
     die();

I get this output: enter image description here

I run this code:

<?php
     $test = $_SERVER['HTTP_HOST'];
     print_r($test);
     var_dump($test);
     die();

I get this output: enter image description here

Why can't print_r() and var_dump() agree on the value of $test in case 1?

For context on how I arrived here. I am running a laravel/homestead vm box, and I'm using Browsersync. Browsersync creates a proxy (localhost:3000) that I connect to, which points to the laravel/homestead vm (192.168.10.10). The proxy changes the value of the Host header when the request passes through it.

Nikita240
  • 1,377
  • 2
  • 14
  • 29

1 Answers1

0

This is an Xdebug bug.

Solution: disable xdebug.

Output with xdebug disabled:

enter image description here

Community
  • 1
  • 1
Nikita240
  • 1,377
  • 2
  • 14
  • 29