Reputation: 642
It seems when using PHP variables like $_SERVER the code snippet ignores the $. For example
{
// 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"
}
}
outputs :
// Debugging
if(_SERVER["REMOTE_ADDR"]=='xxx.xxx.xxx.xxx'){
//run only my ip
}
Upvotes: 5
Views: 981
Reputation: 51
I can't add a comment, but Mark has the correct answer.
$$ places the cursor at the beginning of the $ once VSCode has rendered the string. \ correctly places the cursor where you want it instead of one at every $. So, instead of...
<--cursor-here-->$_SERVER
// before $ gives us
$_SERVER<--cursor-here-->
Upvotes: 0
Reputation: 642
You can't use \ you have to use double $ ..
eg.
// Debugging
if($$_SERVER["REMOTE_ADDR"]=='xxx.xxx.xxx.xxx'){
//run only my ip
}
Upvotes: 8