O'Reilly logo

Sams Teach Yourself PHP in 24 Hours, Third Edition by Matt Zandstra

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Making a Network Connection

So far, we have had it easy. This is because PHP makes working with a Web page on a remote server as simple as opening a file on your own system. Sometimes, though, you need to exercise a little more control over a network connection or acquire more information about it.

You can make a connection to an Internet server with fsockopen(), which requires a hostname or an IP address, a port number, and two empty variables. The empty variables you pass to fsockopen() are populated to provide more information about the connection attempt should it fail. You can also pass fsockopen() an optional timeout integer, which determines how long fsockopen() will wait (in seconds) before giving up on a connection. If the connection ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required