TextMate PHP Snippets: Debug Print

Here are some of the snippets I use with TextMate.

This is an old school way, but I use var_dump() quite often. The following snippets works when you are editing an HTML file.

<?php echo "<pre>"; var_dump(\$${1:variable}); die(); // DEBUGPRINT ?>

Set “Activation” to Tab Trigger “debug”, and set “Scope Selector” to “text.html”

I have the snippet that works inside a PHP script.

echo "<pre>"; var_dump(\$${1:variable}); die(); // DEBUGPRINT

Set “Scope Selector” to “source.php”.

The reason I use // DEBUGPRINT to leave the snippet searchable. I often comment out the entire line just like:

// echo "<pre>"; var_dump($variable); die(); // DEBUGPRINT

You may be able to do the very similar thing in other text editors like Coda.

I didn’t know the <pre> tag makes the output very readable. Thanks to my colleague.

Comments

Post new comment

The content of this field is kept private and will not be shown publicly.