T
T
Twelfth Doctor2017-03-28 22:17:38
phpstorm
Twelfth Doctor, 2017-03-28 22:17:38

Why doesn't PHPStorm see the variable from the included file?

Hello! I have code like this:
index.php

<?php
include ('array.php');
$string =implode ($array);
echo $string;

array.php
<?php
$array = array ( "lemon" => "yellow", "apple" => "green" , "strawberry" =>"red") ;

Program output:
yellow green red
The problem is that my PHPStorm 2017.1 says the $array variable is not declared.
5b578dc5d2c94c4db7d829c8eed86973.jpg
7987eecfd8d84374b5ada0fe4e53563a.jpg
How to solve this problem?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
0
04folgob7fbk, 2021-01-19
@04folgob7fbk

Three options
1) Use less includes and requests
2) Make documentation at the top of the main view file:

/**
 * @var $array это переменная из подключаемого файла
 */

Then the storm will recognize it and will not underline
3) turn off notifications about such errors if there is an include or requie. I do not recommend and I will not show how.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question