Quick snippet to reset all public instance variables inside a PHP class back to their original values. Can’t take credit for the code though. Found it on a website somewhere and have used it in pretty much every class I build. Problem is I can’t remember where it was originally.
Posts Tagged: php
Needed a break from a larger web app I’m working on and this weekend kicked out a couple of WordPress plugins that I’ve had on my idea file for a while now. The first is called rTwit and lets you embed any Twitter feed you want into a post or page. Most of the Twitter… Read more »
Reinstalled MAMP last week because the version I was using didn’t have PHP 5.3 which I needed for a project I’m working on. Had to do some Googling to find the default password for MySQL and how to change. First, the default username is root and password is also root. To update to a password… Read more »
Needed a quick way to go through and trim leading and trailing spaces off of a string array in PHP. I’ve used array_walk to do it before, but with the addition of anonymous functions it makes it a little quicker without having to do a separate function. Love those one line and done techniques.
It’s usually a bad idea to allow php include files to be directly accessed. My general method is to either declare a constant in the index.php and check for that constant in the included file or make sure that the included file doesn’t match $_SERVER[‘REQUEST_URI’]. Sure, either of those work. But I came across a… Read more »
Had a client getting this error when trying to send emails last week and have now spent several hours on Google trying to find a solution. Biggest catch is that other scripts were able to send mail, so it seemed unlikely that it was the host. So I took the phpMailer class and uploaded it… Read more »
Needed a quick and easy way to create a bit.ly URL for another site of mine. Google came through for me. David Walsh posted a short PHP function on his site that takes your bit.ly login, API key, and the URL to shorten and returns a nice, short bit.ly link. Link: http://davidwalsh.name/bitly-php Just put the… Read more »
Working on web apps I find myself using the print_r command a lot, and I mean a lot. It helps trace out what data is going where, and more often what’s not going where it’s supposed to. A few months ago I realized that I type this same bit of code way too often. Does… Read more »
How did I not try this before today? My normal method of needing two files open was to have the one I’m working on in Netbeans and the other in Notepad++ on separate monitors. Turns out you can drag the tab of an open file outside of Netbeans and it becomes its own window. We’re… Read more »
After spending the better part of yesterday getting a forum setup with the same layout as its parent WordPress site I thought I’d share a couple of tips along the way. And I picked a less efficient way, including wp-blog-header.php in the forum code, because it was far easier. At some point I may go… Read more »