Home PHP
PHP
Logical vs Comparison Operators in PHP PDF Print E-mail
Written by Nate Lyman   
Friday, 30 July 2010 04:35

Sometimes, you need to validate a variable passed into a function and set a default value if the user accidentally passes in a NULL.  There are a few ways to do it, a lot of developers would just use an if statement.  But not you, because it takes up extra space.  So basically there are two other easy ways to do it.

You can use a ternary operator, as highlighted in the ternary function.  Which cleans up your code a bit.

Another way is to use the logical operator "or".  In the logical function below, if the user enters in a value such as NULL or FALSE, it will use the default value of 10. Another benefit is, a lot of PHP programmers aren't aware of it.  It gives them a chance to learn something new!

Show/Hidden php code

Last Updated on Friday, 30 July 2010 04:45
 
TEKX Wrap-up PDF Print E-mail
Written by Nate Lyman   
Friday, 04 June 2010 04:40

Let me preface this post with acknowledging that Tek-X ended two weeks ago.  I have been travelling since then and finally caught up on other things. Let me say that Tek-X was by far the best conference I've been to.  All the speakers were excellent and the other attendees were a great group of people.

I found all the sessions had great content but below are the ones I found to be the best.

Notable Sessions

PHP Code Review - Sebastian Bergmann and Arne Blankerts

I saw this talk at CodeWorks 09 so I, as well as my co-worker marked this as a must see talk. They point out obvious WTF's as well as some of the other not-best practices in open source code such as WordPress, CakePHP, etc...  Maybe it is me, but everything is funnier in a German accent.

The Lost Art of Simplicity - Josh Holmes

This was the keynote for day one.  This was a killer talk focusing on finding simple solutions to complex problems and not over engineering things.  I want everyone I work with to attend this talk at some point in the near future.

Anti-Spam and Anti-Gaming - Eli White

This was probably my favorite sessions.  Eli talked about ways to prevent bots from spamming your site among other things.  Some of the ideas were as simple as blocking requests from clients with no user agent, to creating honey pots on forms.  Check out the slides.

Large Scale Systems - David Strauss

A lot of developers will never have to worry about scaling systems at this order of magnitude, but David brought up great examples of where to implement reverse proxies, caching, and methods for full text indexing.

Links

Joind.in - Has reviews of all the sessions as well as links to slides.

Tek - PHP Tek website.  Keep an eye on the site so you can go next year!

Last Updated on Friday, 04 June 2010 05:09
 
HiPHoP vs PHP Round 1 PDF Print E-mail
Written by Nate Lyman   
Thursday, 03 June 2010 22:29

Today I decided I would start benchmarking HiPHoP versus PHP.  For my first test I made a script that simply opens a 1.5 million row file and parses through it line by line.  For each line it sums up the number of characters.

After 100 runs executing the script via PHP and HiPHoP the run times are pretty consistent for both.  With HiPHoP clearly winning the first Round.

I will come up with a more complicated test for the next round.

Graph

 
PHP TekX 2010 in Chicago PDF Print E-mail
Written by Nate Lyman   
Sunday, 16 May 2010 11:19

Hey friends,

I'm packing and getting ready to head to Chicago for PHP TekX 2010.  It is going to be a great week filled with networking, learning, sharing, geek wizardry, and great food.  This year TekX has 30+ great sessions in store for those in attendance.  The sessions I am planning to attend are as follows:

Tuesday (Tutorial Day)

Building a Zend Framework Application
PHP Best Practices

Wednesday

The Lost Art of Simplicity
Working with Zend_Form
Graphs, Edges & Nodes: Untangling the Social Web
Large Scale Systems
PHP Looking into the Future
Code & Release Management
Domain NoSQL: Next Generation Play-Doh

Thursday

10 Developer Trends in 2010
New SPL Features in PHP 5.3
Agile in a waterfall world
Measuring your Code
Get the most of PHP with IIS
HipHop for PHP

Friday

Caching with Memcached and APC
Design Patterns
Cross Platform PHP

Now, most importantly the food.  Here are the places I am planning to hit while in town:

Gene and Jude's (Best Hot Dogs in the World)
Portillo's (Hot Dogs, Italian Beef, Killer Cheese Fries, Chocolate Cake)
Gino's East (Great Chicago Pizza)
Buena Beef

I am really looking forward to meeting all the great members of the PHP community and networking and sharing knowledge.  I know I work on really complicated stuff, and I know others do as well.  It'll be great to get a different perspective and learn from other developers' experience.

 
Is HipHop for you? PDF Print E-mail
Written by Nate Lyman   
Friday, 30 April 2010 14:31

A few days ago I decided I'd give HipHop a try.  For those of you who don't know what HipHop is check out the Facebook blog post.

I wen't on the adventure of setting up a new 64-bit Linux VM at work with CentOS 5 with the bare minimum installed.  To be clear, it took a long time to download/build all the required programs/packages.  There were also a couple snags I ran into while trying to build HipHop itself, but luckily the error reporting is very logical and tells you what is wrong.

So, the question remains, is HipHop for you?

For most people the answer is most likely no.  If you have an enterprise application that requires scaling with hardware because of CPU load concerns, then the answer may be yes.  To even start thinking about migrating to HipHop you should probably have a couple of the following conditions in your environment.

  • Several DEDICATED servers with high CPU load and/or Memory Usage
  • Scaling issues/impending scaling issues
  • Heavy text processing
  • Need for concurrency
  • Time to spare to re-factor your code

 

For my specific case I need a high availability web service that several different applications connect to.  It is currently written in PHP and has it's own scaling issues.

As I go through the process of porting this service to HipHop I will post the snags I run to as well as benchmark comparisons.

 
« StartPrev1234NextEnd »

Page 1 of 4