How to add even and odd classes to posts
Just paste this code within the class attribute of your element and voila!
<?php echo (++$j % 2 == 0) ? 'even' : 'odd'; ?>
Just paste this code within the class attribute of your element and voila!
<?php echo (++$j % 2 == 0) ? 'even' : 'odd'; ?>
Easy as pie: http://bavotasan.com/2010/display-rss-feed-with-php/
<?
// 301 Redirect - if url contains www then redirect to non-www
$current_path = 'http://'.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];
if ( strpos($current_path,'www.') !== false ) {
$current_path = str_replace('www.','',$current_path);
header( "HTTP/1.1 301 Moved Permanently" );
header( "Location: $current_path" );
}
?>
<?php
function getFileextension($file) {
return end(explode(".", $file));
}
?>
Source: http://css-tricks.com/snippets/php/find-file-extension/
<?php
function writeToFile(){
// 'w' overwrites entire file whereas 'a' appends text to it
$filename = 'test.txt';
if (is_writable($filename)) {
$Handle = fopen($filename, 'a');
$Data = "line 1\n".
"line 2";
fwrite($Handle, $Data);
print "Data Written";
fclose($Handle);
}
else {
echo "It's not writable!";
}
}
?>
<?php writeToFile(); ?>
