Never been to DZone Snippets before?

Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

« Newer Snippets
Older Snippets »
Showing 1-3 of 3 total  RSS 

PHP Copyright Updater

// PHP Copyright Updater
// by Evan Walsh
// NothingConcept.com

This code will automatically change the copyright on your site as the year changes. Tested and approved by me.

Just call this in one of your PHP files by including the file with this code in it:

<?php
//Licensed under the GPL v2
//by Evan Walsh of nothingconcept.com
function copyright($site,$year) {
    $current = date(Y);
    if($year == $current) { $eyear = $year; }
    else { $eyear = "$year - $current"; }
    echo "All content &copy; $eyear $site";
}
?>


Example: <?php include('functions.php'); ?>

Then place <?php copyright("Sitename","2007"); ?> or something similar in the place you want the copyright to display.

Simple as that.

PEAR:HTML_QuickForm

HTML_QuickForm($form_name,$http_method,$rel_path,$target,$HTML_attributes)


// use the default method (POST), but change the action URL
$default_form = new HTML_QuickForm('default_form','','/dir/page.php');

// use the default $rel_path as $_SERVER['PHP_SELF']
$get_form = new HTML_QuickForm('get_form','GET');

// set form HTML attributes
$css_form = new HTML_QuickForm('css_form','','','','class="cform" id="css_form"');

// add button with HTML attribute
$css_form->addElement('button', 'close', 'Close','onClick="test();"');

Trimming data contained in an array

function file_trim(&$value, $key)
{ 
   $value = trim($value);
}

$file = file('name.txt');
@array_walk($file, 'file_trim');
« Newer Snippets
Older Snippets »
Showing 1-3 of 3 total  RSS