Basic Code: Functions

  1. Dates and Times
  2. Basic Code
  3. Variables

At its most basic, PHP uses functions to get things done. The functions we just used are the “echo” function and the “date” function. The ‘echo’ function is simple. Whatever you give it, it ‘echoes’ to the web page. In this case, we gave it the ‘date’ function. The ‘date’ function (http://php.net/manual/function.date.php) returns the current date and time in whatever format you want. The format code we used was “h:i A”. This means we want the hour, a colon, the minute, a space, and either AM or PM. If it is currently March 9, 10:11 AM and 14 seconds, this will give us “10:11 AM”, which the “echo” function inserts as part of the web page.

You will use “echo” heavily to output text and HTML to your web page.

  1. Dates and Times
  2. Basic Code
  3. Variables