Skip to main content

  | मौसम…

411 समाचार
Public archive edition · Attributed source reporting with original dates · AI drafts are excluded

411 REFERENCE · Wikibooks

PHP vs ColdFusion/Hello World

Reference material by Wikibooks contributors. This retains its source identity and is not 411 news reporting.

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: main( ) { printf("Hello, world!"); } 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: <html> <head> <title>Test</title> </head> <body> <?php $message = "Hello World!"; echo $message; ?> </body> </html> ColdFusion: <html> <head> <title>Test</title> </head> <body> <cfset message = "Hello World!"> <cfoutput>#message#</cfoutput> </body> </html> 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: 07 <?php 08 $message = "Hello World!"; 09 echo $message; 10 ?> Line#07 <?php Starts allowing php code to be parsed Line#08 Stores $message with the value Hello World! Line#09 echo Dumps the value Hello World! Line#10 ?> Ends php ColdFusion: 07 08 <cfset message = "Hello World!"> 09 #message# 10 Line#07 Starts the ability to output to the browser Line#08 <cfset Stores #message# with the value Hello World! Line#09 #message# Dumps the value Hello World! Line#10 End the ability to output to the browser What the Browser Sees Either way, these two scripts produce the same exact page, the only thing different are the server headers. <html> <head> <title>Test</title> </head> <body> Hello World! </body> </html> Displayed in Browser Hello World!