Skip to content
View in the app

A better way to browse. Learn more.

Web Designer Forum

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

TUTORIAL: Php How To's

Featured Replies

After noticing the success of my php includes tutorial and the feedback received, I decided to create a thread for those who have some knowledge in php to teach those who are new. I soon hope that with the help of users of this forum, to create a e-book with everyones tutorials. Please share your talent in php by creating a tutorial.

 

php date()

Tutorial by: Sazzad Hossain

 

php date() - the PHP date() function formats a timestamp to a more readable date and time. The first parameter in the date() function specifies how to format the date/time. It uses letters to represent date and time formats. Some of these formats include:

 

Important Full Date and Time:

 

* r: Displays the full date, time and timezone offset. It is equivalent to manually entering date("D, d M Y H:i:s O")

 

Time:

 

* a: am or pm depending on the time

* A: AM or PM depending on the time

* g: Hour without leading zeroes. Values are 1 through 12.

* G: Hour in 24-hour format without leading zeroes. Values are 0 through 23.

* h: Hour with leading zeroes. Values 01 through 12.

* H: Hour in 24-hour format with leading zeroes. Values 00 through 23.

* i: Minute with leading zeroes. Values 00 through 59.

* s: Seconds with leading zeroes. Values 00 through 59.

 

Day:

 

* d: Day of the month with leading zeroes. Values are 01 through 31.

* j: Day of the month without leading zeroes. Values 1 through 31

* D: Day of the week abbreviations. Sun through Sat

* l: Day of the week. Values Sunday through Saturday

* w: Day of the week without leading zeroes. Values 0 through 6.

* z: Day of the year without leading zeroes. Values 0 through 365.

 

Month:

 

* m: Month number with leading zeroes. Values 01 through 12

* n: Month number without leading zeroes. Values 1 through 12

* M: Abbreviation for the month. Values Jan through Dec

* F: Normal month representation. Values January through December.

* t: The number of days in the month. Values 28 through 31.

 

Year:

 

* L: 1 if it's a leap year and 0 if it isn't.

* Y: A four digit year format

* y: A two digit year format. Values 00 through 99.

 

Other Formatting:

 

* U: The number of seconds since the Unix Epoch (January 1, 1970)

* O: This represents the Timezone offset, which is the difference from Greenwich Meridian Time (GMT). 100 = 1 hour, -600 = -6 hours

 

I got the list of characters from http://www.tizag.com/

For the complete list click here

 

So basically all you have to do is call the date() function. You can accomplish this by simply using the following call-out after your <body tag or wherever you wish for it to appear. Please note the function echo. "PHP function echo is a means of outputting text to the web browser. Throughout your PHP career you will be using the echo function more than any other" (tizag)

<?php
echo date("ITEMHERE");
?>

Replace ITEMHERE with the designated character from the list above. If you want to display a normal date format, enter the following

<?php
echo date("M. d, Y");
?>

Output for this code is the following: Dec. 15, 2007

 

 

 

Comments

Tutorial by: Sazzad Hossain

 

Lets go back to HTML. In HTML there is only one type of commenting. Unlike HTML, php has two types; single line comment and a multi-line comment.

 

A single line comments tells the reader (server) to ignore everything to the right side of the comment on the line. To complete the single line, we use the two forward slash ( // ) at the very beginning of the comment. All content to the right of the two forward slashes will be counted as comments.

 

Comment example 1

<?php
echo "Welcome WDF Users!"; // YOUR comment can be posted here
echo "<br />Forum with the coolest free templates and services!"; // no one will know what you put here
// you can even comment a function echo "comment a function";
?>

This will output the following

Welcome WDF Users!

Forum with the coolest free templates and services!

 

A multi-line comment can be used to comment out large chunks of code or text (similarly to the HTML comment). The multi-line comment in php begins with a /* (forward-slash followed by asterisk) and ends with */ (asterisk and forward-slash).

 

Comment example 2

<?php
/* This comment cannot be viewed by any normal guests, you can use this sort of comment to remove or not use a certain line of code from your source such as include "home.php" */
echo "Welcome WDF Users!"; 
?>

This will output the following

Welcome WDF Users!

Create an account or sign in to comment

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.