Never been to DZone Snippets before?

Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

About this user

« Newer Snippets
Older Snippets »
Showing 1-2 of 2 total  RSS 

Watch a log and/or search for a certain term

If you're developing on a server that has all PHP errors turned off, you can still watch the error log (if you have access to this file). For example on a dreamhost account you could try this:

tail -f /home/account/logs/website.com/http/error.log

As the errors pour in, you will see them come by. Change 'account' to the username you have on dreamhost and website.com to the domainname you host there. If the errors come in large amounts you can filter them by using grep:

tail -f /home/account/logs/website.com/http/error.log | grep -i "search_term"


Now only errors containing 'search_term' will be shown.

Replace old style PHP tags to new style tags

Sometimes you have to work with scripts that contain old-style PHP tags. This little snippets fixes those scripts, so they use the new style PHP tags.

find * -type f -exec perl -i -wpe 's/<\?php/<\?/g' {} \;
find * -type f -exec perl -i -wpe 's/<\?/<\?php/g' {} \;
« Newer Snippets
Older Snippets »
Showing 1-2 of 2 total  RSS