31 | October 2014 |
Friday |
function Something(){
echo "About something..."; } Something(); |
Read the content or code / instruction -
Add year to current date() and then make an own function statement to run the durable program.
create a function to make website becomes more efficiency; e.g.
// wrap the statement into a functionLess codes repeating but do more functions, make the function re-usable and flexible. For example: Paste the footer() on each footer's page but only adjust on one single function page that maintain all of the pages updated!
Save the function to individual php file. You can use require(), include(), include_once() or require_once(), access the statement and run out the function behavior to indicate page.
// you can use () parentheses with 2 single quotesWhen I visit the other websites, I found out many footers "year" already expired. It will have a bad impression sometimes because we know many websites were abandoned and hanged on the free hosting Servers long times. People will doubt you, "Is your site still alive? 9 years ago with the outdated information ...". Expired makes people doubt the site is an abandoned website. Although the owner can show the updated or add modified post date beside the content, that would be helped. However, people want to see the newest information, once they discover expired years on footer, that much impact the site truthful and value.
see the code OR slideshow instruction
<?php
//example on function.php, set the timezone first
date_default_timezone_set('America/New_York');
function footer(){
$openday = date('Y', strtotime('-2 year'));
$current = date('Y');
echo $openday.' - '.$current;
}
?>
<?php
//example on footer.php or every page footer section
require_once 'function.php';
footer();
?>
Watch next videos and relative source page(s)