S
S
sorry_i_noob2018-12-03 21:51:57
phpstorm
sorry_i_noob, 2018-12-03 21:51:57

Why if I wrap file_get_contents in a function PhpStorm doesn't see $http_response_header?

Hello! There is this code:

<?php

$url = 'https://toster.ru/';

const WITH_WRAP = 1;
const WITHOUT_WRAP = 2;

$mode = WITHOUT_WRAP;

function some_func($url) {
  $result = file_get_contents($url);
  var_dump($http_response_header);
}

switch ($mode) {
  case WITH_WRAP:
    some_func($url);
    break;
  case WITHOUT_WRAP:
    $result = file_get_contents($url);
    var_dump($http_response_header);
    break;
}

If $mode is WITH_WRAP. And if I put a breakpoint on the line:
var_dump($http_response_header);
In some_func. Then PhpStorm does not see the $http_response_header variable. However, it exists - if you continue the execution of the program, then this variable is displayed (calling var_dump).
If $mode is WITHOUT_WRAP. And if I put a breakpoint on the line:
var_dump($http_response_header);
In switch. Then PhpStorm sees the $http_response_header variable.
I am attaching screenshots.
Screenshots
5c057b32c84d9078404806.png5c057b3a48e3a110727891.png

How to fix it?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question