Home PHP
PHP
PHP Tek-X Conference in Chicago PDF Print E-mail
Written by Nate Lyman   
Thursday, 04 March 2010 18:45

Every year the folk at PHP|Architect put on a great conference PHP Tek.  This year Tex-X will be in Chicago and has a killer schedule lined up.  This year, myself and a handful of co-workers went to Code Works in San Francisco, which was also put on by the PHP|Architect folks.  TEK-X promises to build off the sessions we attend there and much more.

 
Arrays vs Objects PDF Print E-mail
Written by Nate Lyman   
Saturday, 20 February 2010 07:50

This post isn't a stab at OOP at all.  This post is to simply show the differences in performance between Arrays and Objects.  For most applications it probably doesn't make a huge difference but if you're working on a large web application or backend job microseconds count.

I will use a snippet of code that does exactly the same thing but store the data in an object and an array.  First lets look at using an object.

Show/Hidden php code

Now, lets examine the difference if you use an array with string keys.

Show/Hidden php code

As you can tell, the array with string kess performs worse than an object.   Lets examine using a numeric key.

Show/Hidden php code

Look at that, nearly twice as fast as both objects and arrays with string indexes.  For the seasoned programmer this comes as no surprise, but for a more junior programmer this is something to keep in mind.  Yes, an assiciative array makes for cleaner code, but can have a pretty big impact on performance at scale.

 
Great PHP Twitter Library PDF Print E-mail
User Rating: / 1
PoorBest 
Written by Nate Lyman   
Monday, 15 February 2010 10:41

Tonight I was updating "That's What She Said" by having the site post new quotes to twitter in real time.  In researching the Twitter API, I explored writing my own Twitter API Class.   It would be easy enough but I decided to see what was out there first.  I am extremely glad I did.

Tijs Verkoyen has written an excellent Twitter API class, that will do pretty much anything you could ever want to do on Twitter.  Not only is it well written, but it is equally well documented.

After the jump, I'll dive deeper into the implementation.

 
Oh, how I love array_combine PDF Print E-mail
Written by Nate Lyman   
Monday, 08 February 2010 08:15

Let me just start by saying that it is late, but I am up late working on parsing a huge text file. 120,000,000 rows huge.  Anyway, let me enlighten you on the awesomeness of array_combine().

Imagine you have some tab delimited file that looks like this:

Show/Hidden php code

Imagine you want to parse this file row by row and load the data of each row into an associative array.  There is an overly complicated way you can do it, as seen below:

Show/Hidden php code

Enter array_combine(). You simply pass it in an array of keys, and the array of values, it returns an associative array. See the same function below using array_combine().

Show/Hidden php code

Obviously this doesn't save you a lot of lines of codes, but it saves you a minute or two.  The point is that you should use PHP's native function instead of writing your own, for readability, as well as performance.  For small arrays you wont see a performance gain, but for a larger array it will run about 30% faster.  Multiply the savings by the number of rows and it can end up being substantial.  This post is to aimed to help a developer that is new to PHP.  There are a lot of other uses for array_combine but I'll let you figure those out.

 
New iPhone template for my site PDF Print E-mail
Written by Nate Lyman   
Monday, 08 February 2010 08:05

I've installed a new theme targeted for users of iPhones.  It will display content in a mobile friendly format.

As you know this site is a Joomla installation, and to get this to work I installed a module called Auto Template Switcher. It lets you target certain browser types (user agents) and send those requests to a special test.  For everyone but iPhone users they will see my normal template.  But iPhone users will see a modified version of NewsPressed Mobile.  To be honest the theme itself is kind of craptastic.  I'll get around to writing one to Apple spec one of these days, but there are bigger fish to fry first.

Finally, the reason this site is using Joomla is because I wanted a turn key solution.  I've got my own CMS framework that I use for other sites, but I didnt want to do a whole lot of customization for this site.

I still have some more awesomization to do here, and as I add them, I will let you know.

 
« StartPrev123NextEnd »

Page 1 of 3

@natelyman

natelyman: Happy 103993/33102 Day!
natelyman: @chitownforte22 it smells like a turd covered in burnt hair!
natelyman: @mikvogel @rgiertz @chriswoods85 Vogel hit the nail on the head.
natelyman: My flight is booked for PHP Tek-X in Chicago May 18-22 Woohoo!