PHP
  Home arrow PHP arrow Implementing Internet Protocols with PHP
Dev Shed Forums  
Administration  
AJAX  
Apache  
BrainDump  
DHTML  
Flash  
Java  
JavaScript  
Multimedia  
MySQL  
Oracle  
Perl  
PHP  
Practices  
Python  
Reviews  
Security  
Smartphone Development  
Style-Sheets  
Web Services  
XML  
Zend  
Zope  
Mobile Linux  
App Generation ROI  
IBM® developerWorks  
Forums Sitemap  
E-Commerce Hosting  
Linux Web Hosting  
Managed Hosting  
Small Business Hosting  
VPS Hosting  
Weekly Newsletter

 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid  
Request Media Kit
Contact Us  
Site Map  
Privacy Policy  
Support  
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
Google.com  
PHP

Implementing Internet Protocols with PHP
By: David Web
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: starstarstarstarstar / 6
    2008-06-03


    Table of Contents:
  • Implementing Internet Protocols with PHP
  • The FTP Application
  • Listfiles Function Explained
  • Listfiles continued

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      error-file:tidyout.log Del.ici.ous error-file:tidyout.log Digg
      error-file:tidyout.log Blink error-file:tidyout.log Simpy
      error-file:tidyout.log Google error-file:tidyout.log Spurl
      error-file:tidyout.log Y! MyWeb error-file:tidyout.log Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article

     
     
    ADVERTISEMENT


    Implementing Internet Protocols with PHP
    ( Page 1 of 4 )

    PHP has many functions that help us to implement Internet and/or networking protocols. In this article, we will look at how to implement some of those protocols using PHP.

    What are protocols?

    Protocols are like rules of communication for a given situation. For example, when you meet someone at night, you would have a conversation that goes something like this:

    “Good evening, how are you doing?”

    Now, you say, “good evening,” because that is the accepted rule for greeting someone at that time of the day. That is a protocol. Computer or Internet protocols work in the same way. For example, to transfer a file, you use the File Transfer Protocol, to send and receive web pages, we use HTTP or Hyper Text Transfer Protocol, and so on. Most of the protocols are described in documents called RFCs, or Request for Comments. These protocols are defined by the Internet Engineering Task Force (IETF) and can be found at http://www.rfc-editor.org

    Since there are hundreds of protocols, we are not going to write about all of them. Instead, we are going to look at the most popular ones. To start with, we are going to create an FTP client that will carry out all of the tasks that a normal FTP client application normally carries out. A useful FTP client will enable you to do the following:

    • Delete files

    • Upload files

    • Download files

    • Move up and down a directory tree

    • Access folders

    And this is what our FTP client application will offer us. So what functions does PHP offer us in this regard? Take a look at the list below:


    Function

    Description

    ftp_cdup($connect)

    Changes to the directory directly above the current directory.

    ftp_chdir($connect, ” directoryname ”)

    Changes directories on the remote computer.

    ftp_close($connect)

    Closes an FTP connection.

    ftp_connect(“ servername ”)

    Opens a connection to the computer (servername can be a domain name or an IP address).

    ftp_delete($connect, path/filename ”)

    Deletes a file on the remote computer.

    ftp_exec($connect, ” command ”)

    Executes a system command on the remote computer.

    ftp_fget($connect,$fh, ”data.txt”,FTP_ASCII)

    Downloads the file contents from the remote computer ($fh is the file handle of the open file).

    ftp_fput($connect ,”new.txt”,$fh,FTP_ASCII)

    $fh is the file handle of the open file.

    ftp_get($connect,”d.txt”, ”sr.txt”,FTP_ASCII)

    Downloads a file from the remote computer (sr.txt is the name of the file to be downloaded, and d.txt is the name of the downloaded file).

    ftp_login($connect, $userID,$password)

    Logs into the FTP server.

    ftp_mdtm($connect, ”filename.txt”)

    Gets the time when the file was last modified.

    ftp_mkdir($connect, ” directoryname ”)

    Creates a new directory on the remote computer.

    ftp_nlist($connect , ” directoryname ”)

    Gets a list of the files in a remote directory. Files are returned in an array.

    ftp_put($connect,”d.txt”, ”sr.txt”,FTP_ASCII)

    Uploads a file to the remote computer (sr.txt is the name of the file to be uploaded, and d.txt is the filename on the remote computer).

    ftp_pwd($connect)

    Gets the name of the current directory on the remote computer.


    The above list does not show all the FTP functions that PHP offers, but it shows the most commonly used functions.



     
     
    >>> More PHP Articles          >>> More By David Web
     

       

    PHP ARTICLES

    - Merging a File Split for FTP Upload using PHP
    - Getting Data from Yahoo Site Explorer Inboun...
    - Method Chaining: Adding More Selecting Metho...
    - How to Split a File During an FTP Upload Usi...
    - Expanding a Custom CodeIgniter Library with ...
    - Using the Yahoo Site Explorer Inbound Links ...
    - Building a CodeIgniter Custom Library with M...
    - Building an E-mini Trading System Using PHP ...
    - Completing the MySQL Class with Method Chain...
    - Building Dynamic Queries with Chainable Meth...
    - PHP Encryption and Decryption Methods
    - Building a MySQL Abstraction Class with Meth...
    - Completing a Sample String Processor with Me...
    - Mastering WHILE Loops for PHP and MySQL
    - Method Chaining: Adding More Methods to the ...





    © 2003-2009 by Developer Shed. All rights reserved. DS Cluster 1 Hosted by Hostway
    For more Enterprise Application Development news, visit eWeek