Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7428901
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T08:53:02+00:00 2026-05-29T08:53:02+00:00

Which method is least expensive on the server? I am dynamically creating directories and

  • 0

Which method is least expensive on the server? I am dynamically creating directories and would like each of them to contain an empty html file. Also how could one measure the difference?

$file = text.html;
$newDest = myDir/text.html;
copy($file, $newDest);

VS

$File = "myDir/text.html"; 
$Handle = fopen($File, 'w');
$Data = ''; 
fwrite($Handle, $Data);  
print "Data Written"; 
fclose($Handle); 
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T08:53:03+00:00Added an answer on May 29, 2026 at 8:53 am

    Copy operations are generally very expensive for a variety of reasons. I ran the following operations each 1000 times to compare them:

     copy
     touch
     fopen, fwrite, fclose
     fopen, fclose //this still creates the file
     fopen //files closed automatically, but this may take up more memory.
    

    touch is consistently twice as fast as any fopen method (all were around the same speed). copy was always the slowest.

    In terms of memory, fopen probably uses more since you have to store the file handle while touch and copy only return booleans.

    In summary, use touch.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Which method View() is called last in the System.Web.Mvc.Controller? Or should I override each
Which method would you recommend to pass data from a child view back to
which method do you prefer for creating dynamic sql queries? formating or streaming? Is
In Java (well, Android's version at least) all objects have a getClass() method which
Consider the following main() method which you would find most iPhone applications: int main(int
Hello I have a simple wcf service like this, with a test method which
I've two separate HTML file and .js file. I have a calculate method which
Which method is preferred? Session.Remove(foo); Session[foo] = null; Is there a difference?
Which method makes the most sense for importing a module in python that is
Which method do you think is the best. Use the System.IO.Packaging namespace? Use interop

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.