The Hebrew University Magnes Press


 View book pages:
  




C H A P T E R 1 Networking

by Kevin Schroeder
C H A P T E R 1 Networking and Sockets Y ou can think of this chapter as a foundational chapter in this book. Several other chapters will rely on what you learn here. This chapter also matters simply because although a lot of stuff happens on the network, PHP developers are often insulated from that stuff . For example, PHP’s file_ get_ contents() function can return, via the streams API, the contents of a remote Web site just as if it were a local fi le. The statement: functions the same way as Thanks to the streams API, this type of functionality is identical regardless of the data source, as long as your distribution of PHP supports the specifi ed protocol. This approach has two upsides: it makes your code much simpler, and it makes your application much faster. Because the entire core PHP functionality is written in C, you get the performance benefi t of running compiled code, and compiled C code is always going to be faster than PHP code ( unless you’ve royally messed up your C). The downside of this approach is that you don’t get as much exposure to the underlying layer. In most situations that’s not a problem, but occasionally you will need to know some of what goes on “ under the covers.” $ data = file_ get_ contents( test. php); $ data = file_ get_ contents( http:// www. php. net/);

Zoom in  zoom  Zoom out
  << Topic >>  | Contents | Index             |<   <<    Page       >>   >|  
C H A P T E R 1 Networking and Sockets Y ou can think of this chapter as a foundational chapter in this book. Several other chapters will rely on what you learn here. This chapter also matters simply because although a lot of stuff happens on the network, PHP developers are often insulated from that stuff . For example, PHP’s file_ get_ contents() function can return, via the streams API, the contents of a remote Web site just as if it were a local fi le. The statement: functions the same way as Thanks to the streams API, this type of functionality is identical regardless of the data source, as long as your distribution of PHP supports the specifi ed protocol. This approach has two upsides: it makes your code much simpler, and it makes your application much faster. Because the entire core PHP functionality is written in C, you get the performance benefi t of running compiled code, and compiled C code is always going to be faster than PHP code ( unless you’ve royally messed up your C). The downside of this approach is that you don’t get as much exposure to the underlying layer. In most situations that’s not a problem, but occasionally you will need to know some of what goes on “ under the covers.” $ data = file_ get_ contents(' test. php'); $ data = file_ get_ contents(' http:// www. php. net/');
Zoom in  zoom  Zoom out
  << Topic >>  | Contents | Index             |<   <<    Page       >>   >|  

MC Press Online - 9781583470992


 Other related titles:
Advanced Guide to PHP on IBM iAdvanced Guide to PHP on IBM i
Advanced Java EE Development for Rational Application Developer 7.5Advanced Java EE Development for Rational Application Developer 7.5
IBM i Programmer's Guide to PHP, TheIBM i Programmer's Guide to PHP, The
IBM WebSphere Portal PrimerIBM WebSphere Portal Primer
Introduction to IBM Rational Application DeveloperIntroduction to IBM Rational Application Developer
JavaScript for the Business DeveloperJavaScript for the Business Developer
Programming PortletsProgramming Portlets

 Already viewed books:
You Want to Do What with PHP?You Want to Do What with PHP?