13.09.2016 Views

PHP and MySQL Web Development 4th Ed-tqw-_darksiderg

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

22 Chapter 1 <strong>PHP</strong> Crash Course<br />

Figure 1.3<br />

<strong>PHP</strong>’s date() function returns a formatted date string.<br />

Calling Functions<br />

Look at the call to date().This is the general form that function calls take. <strong>PHP</strong> has an<br />

extensive library of functions you can use when developing web applications. Most of<br />

these functions need to have some data passed to them <strong>and</strong> return some data.<br />

Now look at the function call again:<br />

date(‘H:i, jS F’)<br />

Notice that it passes a string (text data) to the function inside a pair of parentheses.The<br />

element within the parentheses is called the function’s argument or parameter. Such arguments<br />

are the input the function uses to output some specific results.<br />

Using the date() Function<br />

The date() function expects the argument you pass it to be a format string, representing<br />

the style of output you would like. Each letter in the string represents one part of<br />

the date <strong>and</strong> time. H is the hour in a 24-hour format with leading zeros where required,<br />

i is the minutes with a leading zero where required, j is the day of the month without a<br />

leading zero, S represents the ordinal suffix (in this case th), <strong>and</strong> F is the full name of the<br />

month.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!