# PHP vs ColdFusion/Printable version

The current, editable version of this book is available in Wikibooks, the open-content textbooks collection, at
https://en.wikibooks.org/wiki/PHP_vs_ColdFusion

# Introduction

When it comes to web design, many languages exist to create the structure for web-based applications. We will be comparing the languages PHP and ColdFusion.
PHP and ColdFusion are both created to help design web pages scripted in HTML. Alone, HTML cannot create dynamic content, connect to databases to perform queries, manipulate files or handle form data. This is where PHP and ColdFusion come in. The code between these languages may be completely different, however both have thousands of different functions that let you do everything from data encryption to image editing. We will be showing code examples between the two.

# Hello World

Hello World was seen as early as 1974 in Bell Laboratorie's internal memorandum by Kernighan —Programming in C: A Tutorial— which shows the first known version of the program:
In this tutorial we will use one variable named message to display a string of text.

## Putting it Together

These files should always be created using a program that doesn't include formating, and saves to a non-rich text format such as notepad.exe (Win32), Pico (Command line), Kedit (KDE), or Gedit (GNOME).
PHP:
ColdFusion:

## Line Breakdown

This is a very simple example because they both do the same thing, in the same amount of code. Not too hard so far eh? Lets see what actually makes them tick...
PHP:
ColdFusion:

## What the Browser Sees

Either way, these two scripts produce the same exact page, the only thing different are the server headers.

## Displayed in Browser
# Inserting Variables
## Inserting Variables

Both languages allow you to insert variables at any point. This is very useful if you have many lines of HTML, but only need to insert something simple. We will use the variable we created above.
PHP:
(Note: This will not work in php if short open tags are disabled. This was enabled by default as of php 4.0.0)
ColdFusion:
(Note: It is considered poor form in CFML to place <cfoutput> tags at the beginning and end of a page, as the parser must evaluate every word for variables).
Both examples will print: Message holds: Hello World!

# IF Statements

PHP IF STATEMENT
The conditions are based on the information you want to compare.
So let's assume you want to compare apples to oranges, to see if they are the same.
Now assume that you want to return an answer even if the conditions are not met. You would use what is called an else statement which looks as follows.
ColdFusion is very different in its comparisons. They look as follows
If you notice that it's more of a <> based instead of a structure based. This can be an easier transition for HTML developers as it is tagged based
Now to return an alternate or else you do the almost exact same thing as in PHP, but it looks like this:

# Editors

Picking the right editor is essential for web designers. Here we will cover some of the pros and cons of working with certain editors.

## Studio 8

Studio is a software suite from Adobe Systems that includes Dreamweaver, Flash, and Fireworks 8, in addition to Contribute 3 and FlashPaper 2.
Cost: $900 US
Pros
    Easy to Use: Simple, some more complicated functions in Flash, but no coding necessary.
    Standards Compliant: Complies with W3C

## Frontpage 2003

Frontpage is a very neat and handy utility. It offers people to create websites who know zero HTML.
Cost: $199 US
Pros
    Easy to use: Anyone who can use word, can use Frontpage.
    Projects: You can create projects and Frontpage will automatically re-link documents when filesystem changes occur.
Cons
    Doesn't play nice: Frontpage has a tendency to re-write your document to structure code. This usually wipes out PHP code in the document.
    Overly Re-writes: I dont know how many times i've looked at code by Frontpage to only see a plethora of CSS styles. Can get annoying if you are used to a certain way of coding.
    Poor Design: Code is non-W3C complient and hard to use.
    Lack of Support: No longer supported by Microsoft.

## Notepad

Notepad requires you to know pretty much every aspect of HTML, however a wise choice for people who dont like to be told how to code.
Cost: Free
Pros
    Runs fast: No matter what the system (Windows), notepad always performs.
    No Re-writes: Notepad doesn't re-write anything, because it can't.
Cons
    No Projects: No way to manage your documents without external applications or by manually re-writing.
    No Indent Holding: Notepad does not keep your indents, making you tab in over and over.