Home > Enterprise >  How do I create code snippets for vscode for "print_r" that outputs the contents of the va
How do I create code snippets for vscode for "print_r" that outputs the contents of the va

Time:01-25

How do I create code snippets for vscode for "print_r" that outputs the contents of the variable passed to it, along with the filename and line number of the file where the function is called and Also want proper format print in output screen.

$data = array("Volvo", "BMW", "Toyota");
print_r($data);

I want output Like this : Myname FileNmae lineNumber data

sample output image

CodePudding user response:

Here is how you can achieve it. You have just added this piece of code in your vscode global snippets

"print_r": {
"prefix": "_pri",
"body": [
    "echo '<br>type your name here '.basename(__FILE__).' '.__LINE__.'<pre> data :: '; print_r($$data); echo '</pre>'; exit;"
],
"description": "echo '<pre>'; print_r($data); echo '</pre>;"
},

For More help you can follow this link for a better understanding: enter image description here

  • Related