I'm looking for a function in PhpStorm that transform the string like:
echo "my string: $var1, $var2, $var3";
into something like that:
echo 'my string: '.$var1.', '.$var2.', '.$var3';
Thanks in advance
If you want to add double quotes(") to String, then you can use String's replace() method to replace double quote(") with double quote preceded by backslash(\").
Both single (' ') and double (" ") quotes are used to represent a string in Javascript. Choosing a quoting style is up to you and there is no special semantics for one style over the other. Nevertheless, it is important to note that there is no type for a single character in javascript, everything is always a string!
@DummyHead Here's another approach: if you use single quotes, the sed command is exactly as you type it. If you use double quotes, you must take into account all shell substitutions and elaborations to "visualize" what command is eventually passed on to sed.
Use the String. replace() method to replace double with single quotes, e.g. const replaced = str. replace(/"/g, "'"); . The replace method will return a new string where all occurrences of double quotes are replaced with single quotes.
Install "PHP 1Up!" plugin and restart IDE.
Now you will have new intention available (accessible via Alt + Enter or via light bulb icon):
As others have already mentioned:
{}
, e.g. echo "my string: {$var1}, {$var2}, {$var3}";
First we have to do a little phpstorm setup.
Settings > Editor > General > Smart Keys Please mark this. "Surround selection on typing quote or brace"
Click OK.
Then select the entire code with double quotes. Now press the single quotation key.
Done.
No way. You can explode it in concatenation by hands and then convert quotes:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With