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 6694923
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T06:09:32+00:00 2026-05-26T06:09:32+00:00

If the php://temp (or php://memory ) file is opened more than once, will the

  • 0

If the php://temp (or php://memory) file is opened more than once, will the handles point to the same file? Or will each handle be unique?

I couldn’t find an answer in the php docs, so I’m going to write up a test script to find out. I figured it’s worth asking here so someone else can find the answer easily.

  • 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-26T06:09:33+00:00Added an answer on May 26, 2026 at 6:09 am

    Each handle points to an independent stream. Example:

    $a = fopen('php://memory', 'w+');
    $b = fopen('php://memory', 'w+');
    
    fwrite($a, 'foo');
    fwrite($b, 'bar');
     
    rewind($a);
    rewind($b);
    
    $a_text = stream_get_contents($a);  //=> "foo"
    $b_text = stream_get_contents($b);  //=> "bar"
    
    fclose($a);
    fclose($b);
    

    This is not explicitly documented anywhere, but it is implicit in the documentation for streams and wrappers.

    From the official php documentation on streams in general, it is clear that for the standard case of streams, each file handle is associated with it’s own independent stream.

    And in the documentation on IO stream wrappers, it lists the possible wrappers noting exceptions as they occur. There is an exception listed for the first three (stdin, stdout, stderr):

    php://stdin, php://stdout and php://stderr allow direct access to the
    corresponding input or output stream of the PHP process. The stream
    references a duplicate file descriptor, so if you open php://stdin and
    later close it, you close only your copy of the descriptor-the actual
    stream referenced by STDIN is unaffected.

    But no such exception is listed for php://temp or php://memory. Hence it follows that these would work like normal independent streams.

    Also, there are some comments on these pages that further imply the Independence of these streams.

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

Sidebar

Related Questions

My goal here is to open temp.php, explode by ### (line terminator), then by
I have: $page_file_temp = $_SERVER[PHP_SELF]; which will output: /templates/somename/index.php I want to extract from
PHP stores its session information on the file system of the host of the
I have the following jQuery script: $(document).ready(function() { $.ajax({ url: 'temp.ajax.php', type: 'GET', success:
Within PHP I do: 1.) A temporary table is created: CREATE TEMP TABLE new_table
hey guys i got following error Undefined index: hname in C:\Temp\5Aug2010\job.php on line 38
I have a website that uses ajax jquery and facebox. Demo here : http://temp.nevergone.eu/facebox.php
$('#item').click(function() { $.ajax({ url: 'server.php', type: 'POST', data : {temp : 'aValue'}, success: function(data)
Let's say my server looks like this: /www/.htaccess /www/index.php /www/temp/index.php And my personal IP
I have the following files structure: temp main index.php a.php b.php Here are the

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.