PHP Lab #1: Hello, World

  1. For the following four PHP labs, you'll see a series of activities and questions. You should answer all the questions indicated with a bullet

    in a single file called phplabs.txt that you create in Notepad on your K drive. When you are finished with all the labs, copy this file into S:\Students\homework\cs107\yourusername just like you did for the telnet assignment.

  2. In the classic book The C Programming Language, Brian Kernighan and Dennis Ritchie introduced their readers to programming in C by creating a program that printed the words "Hello, world" on the screen. Since that time, most writers of texts and tutorials on programming systems have begun their exposition with some kind of "Hello, world" program.

    Use Notepad to create a file with the following contents:

    <HTML>
    <HEAD>
    <TITLE>Hello world</TITLE>
    </HEAD>
    
    <BODY>
    <?php
    	print("Hello, world. <BR>");
    	print("PHP is neato. <BR>");
    
    	print("4+8 <BR>");
    
    	print(4+8);
    	print("<BR>");
    
    	$total = 4+8;
    	print("$total <BR>");
    ?>
    
    </BODY>
    </HTML>
    

    Save the file as S:/Students/cs107/yourusername/hello.php

  3. Use a web browser to view your file. If you have saved hello.php in the proper place, the URL http://prism.mathcs.carleton.edu/cs107/yourusername/hello.php should work.

  4. Compare the web browser view line by line with the PHP source code. Answer the following questions:

  5. In your browser, select the "View Source" menu item. Answer the following questions:


Page by Michelle Phillips, Jeff Ondich, and Dave Musicant. Last updated 10.03.02