Posts Tagged ‘PHP’

OOP PHP: What is the Double Colon in Objects/Classes for?

Friday, January 16th, 2009

phpI happen to be the only PHP programmer that I know, so it’s hard to ask your buddy what the heck that :: is used for in some OO PHP programs.  I know you could post it on a forum and get the answer, but I never did.  And Google wasn’t really forth coming when you put :: in a search.  Finally I found it in the PHP documentation:  check out Scope Resolution Operator (::).  In short, it’s used to access Static or Constant members of a class.  Here’s a brief example:

(more…)

Popularity: 14%

ASP.Net C# – PHP Equivalents

Wednesday, September 17th, 2008

ASP.netphp_snow_2008

(more…)

Popularity: 8%

PHP: Using Switch to test Multiple Conditions

Sunday, August 3rd, 2008

Ok, so maybe this is common knowledge, but I still felt a little clever when I figured out this trick.  The situation was that I wanted to test a bunch of different conditions to figure out which time category a date falls into.  It would be fairly simple to do with a bunch of if…then…else’s, but really ugly.  Here’s the trick I came up with…use switch(true), and then set up your cases to evaluate to true or false. Here’s some example code:

(more…)

Popularity: 9%