ColdFusion Main > ColdFusion Articles > PHP vs. CFML
PHP vs. CFML
PHP is a server platform and a scripting language. The scripting language contains many useful built-in functions that enable your pages to display dynamic content. If you have developed with the PHP scripting language, you'll find that the ColdFusion language (ColdFusion Markup Language, or CFML) is quite a bit different, but also similar in many ways.
ColdFusion objects (tags) are all inherently active. Here the tag takes care of the creation and the cleanup. When the tag is placed on a page, it is instantiated by the ColdFusion server. The server takes care of the cleanup as well.
This differs from PHP where you must create an instance of an object, use the object, and then destroy the object. For example, when working with a recordset in PHP, you first create the connection and the recordset:
The ColdFusion code has several advantages that are evident right from the start: it's shorter and more concise. It's also much easier to understand exactly what the code does, even without programming knowledge. Another advantage is that cleanup code isn't required-you don't have to destroy your objects. The server handles those details. Yet another advantage, that may not be apparent from the code, is that you can use this recordset again and again on the same page. You avoid having to reset your pointers as you would in PHP using a mysql_data_seek() or a similar construct.
Another thing you'll notice from the code is that the database MySQL is specified. The PHP code will not work with any other database. You can't simply upgrade your database to MS SQL Server-because the code will not work. You can use a database abstraction layer in PHP to simplify the database communication, but that involves learning another set of rules and more syntax. With ColdFusion, all databases are handled the same way by cfquery. The connection to the database is done in the CF Administrator, and the ColdFusion programmer doesn't have to deal with different syntax.
Next>>