PHP
  Home arrow PHP arrow Implementing Internet Protocols with P...
Dev Shed Forums 
Administration  
AJAX  
Apache  
BrainDump  
DHTML  
Flash  
Java  
JavaScript  
Multimedia  
MySQL  
Oracle  
Perl  
PHP  
Practices  
Python  
Reviews  
Security  
Style-Sheets  
Web Services  
XML  
Zend  
Zope  
Forums Sitemap 
IBM® developerWorks 
Sun Developer Network 
E-Commerce Hosting 
Linux Web Hosting 
Managed Hosting 
Small Business Hosting 
Moblin 
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? 
PHP

Implementing Internet Protocols with PHP
By: David Web
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 4 stars4 stars4 stars4 stars4 stars / 5
    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:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb 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


       · Dear, i think this article about ftp-client based on ftp-functions, not about...
       · i agree that had nothing to do with protocol, but it was nice to see how to use...
     

       

    PHP ARTICLES

    - Sub Classing Exceptions in PHP 5
    - Authentication for Web Application Security
    - Building a Content Management System with Co...
    - Filters and Login Systems for Web Applicatio...
    - Working with the Email Class in Code Igniter
    - Building Your Own System Tray Application Us...
    - Structuring Your Projects for Web Applicatio...
    - Inserting, Updating and Deleting Database Ro...
    - Building Your Own Desktop Notepad Applicatio...
    - Web Application Security Overview
    - Working with the Active Record Class in Code...
    - Generate PDF Documents with PHP on the Windo...
    - Sending Email with PHP Networking
    - Performing Strict Validation with the Code I...
    - The preg_replace_callback() function in PHP





    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 6 hosted by Hostway
    Stay green...Green IT