Is there a way to tell PhpStorm to only evaluate header.php together with footer.php (as a browser would do when running index.php)?
Consider a project containing 4 files
- index.php - server side stuff, business logic
- header.php - html with some php prints
- item.php - html with some php prints
- footer.php - html with some php prints
index.php
<?php
//Do some important stuff
include 'templates/header.php';
foreach($some_array as $item){
include 'templates/item.php';
}
include 'templates/footer.php';
header.php
<!DOCTYPE html>
<html lang="en">
<head><title><?=$foo;?></title></head>
<body>
<div id="main">
item.php
<div class="item"><?=$var;?></div>
footer.php
</div> <!-- close #main -->
</body>
</html>
When I do "Inspect Code..." on a project like this I get errors/warnings of the type "Closing tag matches nothing (at line x)" and similar. Is there a way to tell PhpStorm to only evaluate header.php together with footer.php? I Know that you can opt out "header.php" and "footer.php" from the scope but I would like to evaluate them as a unit.
There seems to be no real solution currently, this is the corresponding ticket: https://youtrack.jetbrains.com/issue/WEB-32239
I managed to remove the warning by simply putting the closing tags into PHP echo statements, e.g.
<?php echo "</div></div>"; ?>
instead of</div></div>
, which stops PHPStorm from analyzing the HTML.