Você está na página 1de 2

09/05/12

PHP Script Tips - Working with Directoris and Files

dev.FYIcenter.com
Search
Custom Search

Home >> FAQs/Tutorials >> PHP Script Tutorials and Tips

PHP Tutorials by FYIcenter.com: Downloading and Installing PHP Understanding String Literals and Operations PHP Built-in Functions for Strings Understanding PHP Arrays and Their Basic Operations PHP Built-in Functions for Arrays Creating Your Own Functions Reading and Writing Files Working with Directoris and Files Processing Web Forms Understanding and Managing Cookies Understanding and Using Sessions Working with MySQL Database Uploading Files to Web Servers More... PHP Tutorials Directory: NEW A comprehensive directory of well written PHP tutorials with 300+ entries and growing. All entries are reviewed and edited by FYIcenter.com. Visit PHP Tutorials Directory... Add Your PHP Tutorials... Other Tutorials by FYIcenter.com: XHTML Tutorials & FAQs (182 entries) CSS Tutorials & FAQs (83 entries) RSS Tutorials & FAQs (49 entries) PHP Tutorials & FAQs (204 entries) MySQL Tutorials & FAQs (268 entries) Oracle Tutorials & FAQs (400 entries) SQL Server Tutorials & FAQs (442 entries) More... Related Resources: Developer Resources More...

PHP Script Tips - Working with Directoris and Files


By: FYICenter.com

Home Search Link to Us Developer Jobs Post Jobs Interview Questions Tutorials/FAQs Tutorials Directory Ads by Google

Part: 1 2
Easy, Realistic tests in 10 minutes Download Free 30 Day Trial Now
www.Ne otys.com /Ge t_Ne oLoad

Web Load Testing Tool

A collection of 8 tips on PHP functions for working with file systems: 1. How To Create a Directory? 2. How To Remove an Empty Directory? 3. How To Remove a File? 4. How To Copy a File? 5. How To Dump the Contents of a Directory into an Array? 6. How To Read a Directory One Entry at a Time? 7. How To Get the Directory Name out of a File Path Name? 8. How To Break a File Path Name into Parts? How To Create a Directory? You can use the mkdir() function to create a directory. Here is a PHP script example on how to use mkdir(): <pp ?h i (ieeit(/epdwla"){ f fl_xss"tm/onod) pit"ietr arayeit.n) rn(Drcoy led xss\"; }es { le mdr"tm/onod) ki(/epdwla"; pit"ietr cetd\"; rn(Drcoy rae.n) } ? > This script will print: Drcoycetd ietr rae. If you run this script again, it will print: Drcoyarayeit. ietr led xss How To Remove an Empty Directory? If you have an empty existing directory and you want to remove it, you can use the rmdir(). Here is a PHP script example on how to use rmdir(): <pp ?h i (ieeit(/epdwla"){ f fl_xss"tm/onod) rdr"tm/onod) mi(/epdwla"; pit"ietr rmvd\"; rn(Drcoy eoe.n) }es { le pit"ietr de nteit\"; rn(Drcoy os o xs.n) } ? > This script will print: Drcoyrmvd ietr eoe. If you run this script again, it will print: Drcoyde nteit ietr os o xs. How To Remove a File? If you want to remove an existing file, you can use the unlink() function. Here is a PHP script example on how to use unlink(): <pp ?h i (ieeit(/eptd.x"){ f fl_xss"tm/oott)

Script The Script PHP Script


Related Websites: Software QA Info Developer Resources DBA Resources Tutorial Directory Windows Information BioTech Resources Link Directory Job Forums

Selected Developer Jobs: US-CA-FoothillRanch: Principal Software Engineer - - 08-May-2012 US-GA-Columbus: Lead System Software Analyst - - 08-May-2012 US-CA-SanDiego: Staff Software Engineer - - 07-May-2012 US-MA-Westford: Senior Software Sustaining Engineering Manager - - 07May-2012 US-CA-SantaClara: Software Engineer - 04-May-2012 More...

dev.fyicenter.com/faq/php/php_file_system_function.php

1/2

09/05/12

i (ieeit(/eptd.x"){ f fl_xss"tm/oott) uln(/eptd.x"; nik"tm/oott) pit"iermvd\"; rn(Fl eoe.n) }es { le pit"iede nteit\"; rn(Fl os o xs.n) } ? > This script will print: Fl rmvd ie eoe. If you run this script again, it will print: Fl de nteit ie os o xs. How To Copy a File?

PHP Script Tips - Working with Directoris and Files

If you have a file and want to make a copy to create a new file, you can use the copy() function. Here is a PHP script example on how to use copy(): <pp ?h uln(/epmPn.x"; nik"tm/yigee) cp(/idw/ytm2pn.x" "tm/yigee) oy"wnossse3/igee, /epmPn.x"; i (ieeit(/epmPn.x"){ f fl_xss"tm/yigee) pit" cp o pn.x i cetd\"; rn(A oy f igee s rae.n) } ? > This script will print: Acp o pn.x i cetd oy f igee s rae. (Continued on next part...)

Part: 1 2
Mechanical & Digital Switch For Refrigeration or Heating
www.dwye r-inst.com

Temperature Switch

Copyright 2011 FYIcenter.com

dev.fyicenter.com/faq/php/php_file_system_function.php

2/2

Você também pode gostar