Last modified on 4 May 2009, at 03:46

PHP vs ColdFusion/Inserting Variables

Inserting VariablesEdit

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:

Message holds: <?=$message; ?>

(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:

Message holds: <cfoutput>#message#</cfoutput>

(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!