Fixed tempnam() creates paths with '//'

Sync with PHP's implementation

Closes #3313
Thank you Sara. I'v updated it.