A Web Development Blog Focused on Code and Technology
Archive for September, 2009
By Karthik Viswanathan on Sunday, September 27th, 2009 | 7 Comments »
Let’s say that you have just created a new company and are in need of a contact form. For this form, you want to let the user provide a name, e-mail (so you can get back to them), and a message. In order to make sure you are receiving valid content, it is vital that you check and manipulate user input in order to meet your needs.
For example, what if you wanted the message to be in a strict format, like so:
Every Word In A Sentence Must Be Capitalized. There Must Be No Html Tags And The Rest Of The Letters Have To Be Lower Case. In Addition, No Excess Whitespace Must Exist On Each End Of The String.
By Patrick Lin on Saturday, September 19th, 2009 | No Comments »
Last time, we showed you how to set up alternate color schemes using PHP. As promised, we will now show you how to remember the user’s choice.
We will once again make use of PHP, this time cookies. We will explore how to set the cookie for the user’s choice, and two methods of using this information.
First, we shall create a file. For purposes of demonstration, this file shall be called
By Karthik Viswanathan on Sunday, September 13th, 2009 | 27 Comments »
Creating a beautiful and eye-catching website can often require you to have a hefty CSS file. Unfortunately, this side-effect takes away from your visitors experience; they spend more of their time downloading rather than viewing. In essence, a balance needs to be reached in order for full optimization.
Solving the problem
One simple way to achieve this balance is by using a minifier. By taking a CSS file in as input, a minifier removes white space and other unnecessary elements to significantly reduce file size.
By Patrick Lin on Thursday, September 10th, 2009 | 2 Comments »
One great use for PHP is alternate content depending on different inputs. In this article, we will show how to serve up alternately colored style sheets via PHP.
Disclaimer: This makes use of CSS variables, over which there has been much debate. This article will not discuss whether one should or should not use CSS variables, only present a way to use them.
First, the call in the HTML will no longer call a CSS file, but a PHP file.
<link rel="stylesheet" type="text/css" file="styles.css" />
<link rel="stylesheet" type="text/css" file="styles.php?color=green" />
color can be any nomial you wish, and
green can be any color you wish, or even the name of a color scheme, such as
By Karthik Viswanathan on Sunday, September 6th, 2009 | No Comments »
When it comes to any skill, reinforcing the basics can pave the way for a boundless future. Indeed, taking a step back and presenting simple topics promotes a better form of comprehension. Thus, today’s post focuses on one primordial PHP function: how to delete the first character of a string.
To accomplish this task, you should be familiar with PHP’s
substr( $string, $start, [ $length ] ) function. When used with only the first two parameters, substr returns all characters in
$string from index
strlen( $string ) - 1 (the end), inclusive. Note that the first index of a string is actually zero.