PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
Moderator: General Moderators
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098 Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia
Post
by Chris Corbyn » Tue Aug 15, 2006 6:41 am
Maybe I'm just imaging it but I seem to remember stubmling across a function/set of functions on php.net which allow you to do something like:
Code: Select all
$handle = this_mystery_function_i_cant_remember();
fwrite($handle, 'something');
echo fgets($handle);
You actually define what happens when you fwrite to the handle and when you fget from it. It doesn't create a file, or a socket AFAIK... it just operates on a variable.
Am I completely imaging this or does this function exist? I can't find it
sweatje
Forum Contributor
Posts: 277 Joined: Wed Jun 29, 2005 10:04 pm
Location: Iowa, USA
Post
by sweatje » Tue Aug 15, 2006 6:55 am
I think perhaps your are fseeking the
stream functions.
Jenk
DevNet Master
Posts: 3587 Joined: Mon Sep 19, 2005 6:24 am
Location: London
Post
by Jenk » Tue Aug 15, 2006 8:35 am
one of these?
I would try to hazard a guess, but I'm not even sure I've ever heard of some of those on there..
feyd
Neighborhood Spidermoddy
Posts: 31559 Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA
Post
by feyd » Tue Aug 15, 2006 8:38 am
It sounds like the stream functions..
Oren
DevNet Resident
Posts: 1640 Joined: Fri Apr 07, 2006 5:13 am
Location: Israel
Post
by Oren » Tue Aug 15, 2006 9:01 am
From the manual:
Code: Select all
<?php
$temp = tmpfile();
fwrite($temp, "writing to tempfile");
fseek($temp, 0);
echo fread($temp, 1024);
fclose($temp); // this removes the file
?>
The above example will output:
writing to tempfile
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098 Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia
Post
by Chris Corbyn » Wed Aug 16, 2006 7:01 pm
Oren wrote: From the manual:
Code: Select all
<?php
$temp = tmpfile();
fwrite($temp, "writing to tempfile");
fseek($temp, 0);
echo fread($temp, 1024);
fclose($temp); // this removes the file
?>
The above example will output:
writing to tempfile
Not that
You guys were right.. It was the stream functions I was after. Thanks indeed!