Home > PHP > PHP – Example 0002

PHP – Example 0002

Second Example 0002

<title>Second example</title>

// Second Example
// ————————
echo “Today is ” . showDate();
function showDate(){
$date = getdate();
return ($date[“mday”] . “-” . $date[“mon”] . “-” . $date[“year”] );

In this example we see a call to a function (i.e. showDate()).
The output is depending of the day when you execute it.
The variable $date is the date, and the value is obtained thanks to getdate() function;
The following values are
Day = $date[“mday”]
Month = $date[“mon”]
Year = $date[“year”]
and using the return command, you can output the value of Day, Month and Year and then you have to use “.” you concatenate them.

We explain better in the next lessons.

Categories: PHP
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: