I would expect that you're going to run into a lot of hurdles trying to do this. PHP usually runs as a very unprivilidged user, www, nobody, or apache, and usually won't have permissions to edit user login information.
I suspect that you might be able to use 'sudo' or 'su' to get the correct permissions... but it could be a rather large security issue.
From the command line this might be easier... but then I don't see the advantage over adduser, passwd, etc...