似乎在使用 $_SERVER 之类的 PHP 变量时,代码片段会忽略 $.例如
{
// Example:
"IP Address Test": {
"scope": "php",
"prefix": "iptest",
"body": [
"// Debugging",
"if($_SERVER[\"REMOTE_ADDR\"]=='${1:ipaddress}'){",
"\t//run only my ip",
"\t$0",
"}"
],
"description": "Test only from IP address"
}
输出:
// Debugging
if(_SERVER["REMOTE_ADDR"]=='xxx.xxx.xxx.xxx'){
//run only my ip
}
最佳答案
你不能使用\你必须使用双 $ ..
例如。
// Debugging
if($$_SERVER["REMOTE_ADDR"]=='xxx.xxx.xxx.xxx'){
//run only my ip
}
关于visual-studio-code - 如何在 Visual Studio 代码片段创建中转义 $,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57104208/