How to Strip Whitespace from a String with PHP

By Josh Sherman
1 min read
development
php

Whitespace, it can make all the difference in the world when attempting to determine if a string is empty or not. Anytime you are working with user input I recommend stripping whitespace from both sides of the string. When stripping whitespace you can choose to strip from both sides or […]

How to Increment / Decrement a Number with PHP

By Josh Sherman
1 min read
development
php

Incrementing and decrementing a variable can be accomplished with C-style pre- and post-operators. The pre-operators return the value after it as been incremented or decremented, post- return the value before. Let’s take a look at incrementing first: $i = 1; echo ++$i; // outputs 2 echo $i++; // also outputs […]

While you were out - `while` loops in PHP

By Josh Sherman
1 min read
development
php

while loops are considered the simplest type of loop in PHP-dom. Their purpose is to continue to execute until a condition has been met. Let’s look at an example related to the title, a pseudo-script that will collect messages while you’re out, returning at 1pm (like a lunch break ;): […]

Version Control for Individuals

By Josh Sherman
4 min read
development
version control system
github
gitlab

I find with a lot of folks I interact with, version control is considered something that you use when you are working on a team with multiple contributors. As an individual that is usually the sole contributor of my own projects, I have to disagree as version control is still […]

New Lines in Command-line PHP Output

By Josh Sherman
1 min read
development
php
command-line

If you’ve ever worked with command-line PHP and outputted text you know that PHP takes absolutely no liberties with injecting line breaks into the output. There’s also no magic function or configuration variable that will adjust this behavior. Easy enough, you want line breaks, just add them! echo "I am […]