It's very dependent on server settings. Either 0666/0777 if your PHP runs as "nobody" (the web server user) or 0644/0755 if it runs as "your" user (suPHP for example).
I suppose doing some things via the CLI could trigger some problems as the context is very different from normal (so our normal chmod decision detection ends up giving different results). However, if you run the command as the same user that PHP normally runs as, that should solve that issue.