ColdFusion vs PHP
In my work as a web developer, I write both ColdFusion and PHP code for different projects. I much prefer to develop in the CFML language instead of PHP because I find it to be cleaner and simpler. So, I thought I'd write up a few examples and see what the community at large thinks of them. If you've never tried ColdFusion before and what I write is persuasive, I hope that you'll give the free developer version a try. If you disagree, please let me know-- perhaps I'll learn a better way to do things in PHP.
Here are a few examples:
Looping through query output: This is probably my greatest annoyance with outputting data in PHP. In CFML, you can just call CFOUTPUT or CFLOOP and specify which query to loop through, and the variables are automatically accessible to your code. The number of records in the dataset is easily accessible as part of the query object if you need it, but both of the above tags will handle it for you. With PHP, you first have to write a loop for the correct number of rows, which you as the developer have to determine with a database-specific function. Then, for each row, you have to call another database-specific function which can return either indexed- or non-indexed array containing the row's data. What if your rows need to be grouped? In CFML it's easy; just specify a group="[columnName]" attribute in your CFOUTPUT call. You can even code multiple levels of grouping with the same, easy syntax. But with PHP, I'm not even sure how to do this best; I rely on a complicated set of logic where I store the value from the previous row and compare it to the current row to see if it belongs to the same group.
Query caching:
CFML has great query caching control, where you can choose the length of the cache time-- or even refresh the cache early if content changes. With PHP, you have to load the memcache library.
Query of queries:
I know that PHP doesn't have query-of-queries at all, and what a great feature it is to have. It sure makes queries run quickly and efficiently if you can just query another query already in memory instead of hitting the database every time.
Database transactions:
I'm not even sure how to create transactions natively in PHP, my best guess is that you can't specify them-- instead, you would have to write them into your SQL. But with CFML, you don't have to worry about writing in a COMMIT statement into your SQL. Instead, you just wrap the CFTRANSACTION tag around as many queries as you like (of course, the database you're using needs to support transactions for the tag to work).
Writing SQL queries:
Since ColdFusion stores database connection information (or reads it from the system DSN settings), you don't have to do all of the steps for the same purpose as you do in PHP. Plus, only CFML offers the cfqueryparam tag, which allows SQL Server to cache its query execution plan.
Making HTTP calls:
With CFML, you don't have to worry about whether you have the correct external library installed like you do with PHP; you just write one line with the CFHTTP tag. In PHP, you first have to load the library, configure it with several lines, and then call the URL.
Using lists:
I don't know of any PHP functions that make it as easy to handle lists as CFML does. Sure, in PHP you can split or chunk a string into an array. But that takes an extra step and involves translating your original data into something else.
End of session control:
In most web application environments, you have no way of knowing whether someone's session has expired (unless they've done you the favor of clicking on your site's "Logout" link). In this circumstance, it's impossible to run code at the end of someone's session because you have no idea which page request is the last. But for ColdFusion, that changed in version 7, which has a method called onSessionEnd. Any code in that method will be executed even without a request from the user. Being able to execute code at the end of a session is fantastic for tracking user behavior and other marketing efforts. So far as I know, this is not available in PHP.

