3

崇高なテキスト 2 で次のスニペットを作成しましたが、それを PHP スクリプト内で使用すると、すべての変数 (値ではない) が自動的に削除されます。

<snippet>
<content><![CDATA[

include 'constants.php';

// Defining connection

$connection = mysqli_connect(HOST, USERNAME, PASSWORD);

// If unable to connect

if(!$connection)
{
$error = 'Unable to connect to database server';
echo $error;
exit();
}

// Checking the encoding

if(!mysqli_set_charset($connection, 'utf8'))
{
$error =  'Unable to set database connection decoding';
echo $error;
exit();
}

// Selecting Database

if (!mysqli_select_db($connection, DATABASE))
{
$error = 'Unable to locate the .'. DATABASE;    
echo $error;    
exit();
}
]]></content>
<!-- Optional: Set a tabTrigger to define how to trigger the snippet -->
<tabTrigger>phpMysqlConnection</tabTrigger>
<!-- Optional: Set a scope to limit where the snippet will trigger -->
<!-- <scope>source.php</scope> -->
</snippet>

本当に何が起こっているのですか?

4

2 に答える 2

22

各「$」をバックスラッシュ「\」でエスケープする必要があります。

\$error;
于 2012-08-08T14:37:31.243 に答える
3

崇高なテキストではプレースホルダーに $ 記号が使用されているため、変数の前に \ 文字を配置します。

于 2012-08-08T14:16:38.960 に答える