Developers cut from a certain cloth should know that they should not reinvent the wheel, which is essentially, go out of their way to implement something if it has already been done before.
For instance, if you're interested in writing an IM program, you wouldn't reimplement the communication protocol - you would use libpurple, which provides those libraries for you.
This is an important part of the open source movement - why build your kernel? Just use the linux kernel.
However, as developers, the thought of a bad developer is one who reinvents the wheel. They're the ones whose code gets sent to websites like the Daily WTF, and someone such as Jeff Atwood tells you how horrible you are, and tells you to not reinvent the wheel.
However, I'm going to say that if a better solution exists, you should use it. However, you should be encouraged to reinvent the wheel, if either the solution exists but is not useful (such as a horrific implementation of the solution), or if the solution is unfriendly for you use. Then you should reinvent the wheel to develop a better, solution. The most important part of this is that you should release this into the public domain.
Of course, if there is a standard library implementation, I'd encourage you to not take that advice. I'm specifically talking about function implemented by a library, or a certain module of your program (like a kernel in an OS, or a communications protocol). You should learn it if it's in the domain of the language that you're using, unless it's horrifically insecure.
Of course, in the case above, there are numerous of good libraries to reinvent PHP's less secure features, so you don't have to reinvent the wheel in the first place.
So, in short - reinvent the wheel if the current solution doesn't work for you, unless it's a standard library implementation of something, which in case you should use that unless it's insecure, because you should learn the implementations in the language you are using. Unless you're using PHP, in which case, you might have to use an external library, anyways.