我<<<heredoc heredoc;在函数内部(在类中)使用它,它弄乱了其下面所有代码的语法突出显示。
可以在函数外部使用它,或者在函数内的一行上使用它:
但是如果我在函数中使用它(而不是在一行上),它会弄乱其下面的突出显示,并且我的编辑器(在 Atom 或 Sublime Text 中相同)似乎认为它与函数和类之外的函数和类一起关闭。发生了什么?
<?php
class SimpleCMS {
var $host = 'localhost';
var $username = 'root';
var $password = '';
var $table = '';
public function display_public() {
}
public function display_admin() {
return <<<ADMIN_FORM
ADMIN_FORM;
}
public function write() {
}
public function connect() {
mysql_connect($this->host, $this->username, $this->password) or die('Could not connect to the database. ' . mysql_error());
mysql_select_db($this->table) or die('Could not select database. ' . mysql_error())
// build the database
return …Run Code Online (Sandbox Code Playgroud)