To anyone interested, the final commented examples are on the Web at:
www.springtimesoftware.com/example-copy.txt
and
www.springtimesoftware.com/example-ssh2.txt
Both do the authentication and file upload of a tiny test file in about
1 to 2 seconds, using slightly different functions.
The examples have most error handling removed, as such handling is not
essential to understanding the examples and as all errors seem to be
reported by PHP without special handling, at least on my computer.
There will be some PHP.ini and other notes when I publish these.
I plan to add them to the PHP Manual via GitHub push sometime soon.
A big thank-you to Eric Wheeler, without whom these examples would only
have remained a faint hope. He was willing to work hard to make SFTP
work in PHP.
David