【问题标题】:Sublime Text 2 Php Snippet omitting variablesSublime Text 2 Php Snippet 省略变量
【发布时间】:2012-08-05 15:57:17
【问题描述】:

我在 sublime text 2 中创建了以下 sn-p,但是当我在 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>

到底发生了什么?

【问题讨论】:

  • 删除所有“$connection”和“$error”变量

标签: php code-snippets


【解决方案1】:

在变量前面放一个 \ 字符,因为 sublime 文本使用 $ 符号作为占位符。

【讨论】:

    【解决方案2】:

    您需要使用反斜杠“\”转义每个“$”。

    \$error;
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-06-22
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-02-18
      相关资源
      最近更新 更多