Wednesday, 6 April 2011

Week 7 - Introduction to PHP

In this week's lesson, PHP have been introduced and the following tasks have been given:
  • Using your browser, verify that PHP is working on your web server.
  • Create an associative array of user names and passwords and list the entire array in a table.
  • Explain the difference between the echo() and print() functions.

Testing PHP

Last week to verify that PHP is working I created a file named hello.php that have a phpinfo function (line 4). I added an additional line where a heading "PHP info Report" will be shown at the center of the page before the php info report.

Associative Arrays

An associative array of user names and passwords have been created where the entire array was listed in a table. Associative arrays allows access through keys and are used to access many important values in PHP, Moseley (2007)[1].


Difference between echo() and print() functions

The print function always return 1 as a value but can be ignored, while echo is faster because it will not return 1 as a value, Moseley (2007)[1]. Also the echo function can take more than one expression, while the print cannot as discussed in
http://community.invisionpower.com/topic/166459-php-difference-between-echo-and-print/.

[1] Moseley, R. (2007) Developing Web Applications.

No comments:

Post a Comment