Search code examples
phpphpstormlive-templates

How can I dynamically create a php variable in a PhpStorm live template?


I'm trying to create a live template in PhpStorm but I'm having trouble with dynamically creating variables. I'm trying to do something like this:

$$VARIABLE_NAME$ = function($END$)
{

};

$this->foo(array('$VARIABLE_NAME$' => $$VARIABLE_NAME$));

Let's say that we type in 'bar' for the $VARIABLE_NAME$, I want to get the following result:

$bar = function()
{

};

$this->foo(array('bar' => $bar));

Basically I need a way to escape $VARIABLE_NAME$ so that it creates a php variable with the value you enter for it. Does anyone know how to do this?


Solution

  • Sure, just use $$ for actual dollar sign.

    This means that you have to replace your $$VARIABLE_NAME$ by $$$VARIABLE_NAME$