如何在 Visual Studio 代码片段创建中转义 $
How to escape $ in Visual Studio Code snippet creation
似乎在使用像 $_SERVER 这样的 PHP 变量时,代码片段忽略了 $.例如
{
// Example:
"IP Address Test": {
"scope": "php",
"prefix": "iptest",
"body": [
"// Debugging",
"if($_SERVER[\"REMOTE_ADDR\"]=='${1:ipaddress}'){",
"\t//run only my ip",
"\t[=11=]",
"}"
],
"description": "Test only from IP address"
}
}
输出:
// Debugging
if(_SERVER["REMOTE_ADDR"]=='xxx.xxx.xxx.xxx'){
//run only my ip
}
你不能使用 \ 你必须使用 double $ ..
例如。
// Debugging
if($$_SERVER["REMOTE_ADDR"]=='xxx.xxx.xxx.xxx'){
//run only my ip
}
似乎在使用像 $_SERVER 这样的 PHP 变量时,代码片段忽略了 $.例如
{
// Example:
"IP Address Test": {
"scope": "php",
"prefix": "iptest",
"body": [
"// Debugging",
"if($_SERVER[\"REMOTE_ADDR\"]=='${1:ipaddress}'){",
"\t//run only my ip",
"\t[=11=]",
"}"
],
"description": "Test only from IP address"
}
}
输出:
// Debugging
if(_SERVER["REMOTE_ADDR"]=='xxx.xxx.xxx.xxx'){
//run only my ip
}
你不能使用 \ 你必须使用 double $ ..
例如。
// Debugging
if($$_SERVER["REMOTE_ADDR"]=='xxx.xxx.xxx.xxx'){
//run only my ip
}