Josh Ashmore's Blog

Today is Sunday, November 18th, 2018.

You made your bed, now lie in it!
May 23, 2017 by Josh

Why do they say, “You made your bed, now you have to sleep in it”? It's just that, using the words "have to" makes it sound like punishment. Well that's what we mean, isn't it? We mean to say that, "you made a decision, and now you have to live with it". But it doesn't sound like a very bad punishment to lie in a bed that you already made. If anything, we should be saying, “You never made your bed, but now you have to sleep in it.”

Read more »


How to make an automatic copyright year in PHP
January 1, 2016 by Josh

This is probably the most useful trick you'll learn when creating a website.

<?php
        echo "Copyright " . date('Y') . ". All Rights Reserved.";
?>

Read more »


PHP shorthand if / else (ternary) examples
February 16, 2015 by Josh

Some helpful code snippets I found on the web to help you shorten your time.

// Test for admin privileges
$is_admin = ($user['permissions'] == 'admin') ? true : false;
// Customize greeting for site users
echo 'Hello ' . ($user['is_logged_in'] ? $user['first_name'] : 'Guest') . '!';
// Find out if it's a leap year
$is_leap_year = ((($year % 4) == 0) && ((($year % 100) != 0) || (($year %400) == 0)));
// Send user to a different page based on valid login
header('Location: ' . ($valid_login ? '/members/index.php' : 'login.php?errors=1'));

Read more »


Easy website templates with .htaccess
August 11, 2015 by Josh

With a few lines of code, you can easily add content before and after each page in a directory without using require() or include() PHP commands.

# Prepend to the file
php_value auto_prepend_file "includes/header.php"
# Append to the file
php_value auto_append_file "includes/footer.php"

Read more »

About

Josh Ashmore is a freelance web designer, full-stack developer, aspiring artist and blogger based in Houston, Texas where he works full time in restaurants and IT Support.