I created a simple function that is roughly equivalent to .Net’s Path.Combine method. This function combines two strings into a path. However, this only handles when to place path separators in between the two strings given. It works by trimming off separator characters on the left side of $path1 and the right side of $path2, which is then concatenated as $path1, the directory separator character, and $path2. The function also works with URLs.
As a theme or plugin developer, WordPress debugging may be a pain as some errors may not be specific, especially if you have a giant class->function call stack. With this simple script, you can view the call stack of the errors you get.