[英]PHPStorm - Suggestions in included HTML
I can not see suggestion for variable $data
in Default.phtml
if I include HTML file Default.phtml
from class Code_Controller.php
method. 如果我从类
Code_Controller.php
方法中包含HTML文件Default.phtml
,我在Default.phtml
中看不到变量$data
建议。 Here is a code example. 这是一个代码示例。
Code_Controller: Code_Controller:
abstract class Core_Controller{
protected $template;
public function display(){
$data['title'] = 'Title of site';
if(Core_Config::$is_admin){
require_once ADMIN_TEMPLATES_PATH . $this->template . '.phtml';
}else{
require_once PUBLIC_TEMPLATES_PATH . $this->template . '.phtml';
}
}
}
Default.phtml Default.phtml
<!DOCTYPE html>
<html>
<head>
<title><?php echo $data['title'] ?></title>
</head>
<body>
The content of the document......
</body>
</html>
Have anybody some idea? 有人有点想法吗?
Thanks for advice. 谢谢你的建议。
Standard approach in such case: use PHPDoc and declare that variable there (at the top of the file), eg 在这种情况下的标准方法:使用PHPDoc并在那里声明该变量(在文件的顶部),例如
<?php
/** @var array $data */
?>
...HTML CODE HERE...
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.