could someone please tell me what fp stands for/means
used in:
PHP Code:@ $fp = fopen("order.txt", "a");
if (!$fp)
{
echo "<p>Your order could not be processed at this time</p>.";
exit;
![]()
![]()
| SitePoint Sponsor |




could someone please tell me what fp stands for/means
used in:
PHP Code:@ $fp = fopen("order.txt", "a");
if (!$fp)
{
echo "<p>Your order could not be processed at this time</p>.";
exit;
![]()
![]()
coiL
"cradled in the learning curve"
$fp is just a variable it could have the value of anything.
$fp = anything you like.![]()
If you like the look of my slippers you should see my undies!


As a newbie you should really get to know the manual:
http://www.php.net/manual/en/
Definately keep aking questions here, but the maual is invaluable as a referance resource, and it has a decent "newbie" tutorial.
guys, you could have been more useful by adding that, in this particular case (looking at the code) $fp is a file pointer (hence the name...it's actually a bit of a standard to call it $fp, if i'm not mistaken), as it holds information which enables other functions etc to access that particular file that you opened with the fopen function...
but yeah...
re·dux (adj.): brought back; returned. used postpositively
[latin : re-, re- + dux, leader; see duke.]
WaSP Accessibility Task Force Member
splintered.co.uk | photographia.co.uk | redux.deviantart.com


actually that is not a complete answer. You can call it what you want, but its not just any variable. Its the handle that this particular php script will assign the file you opened. Certain functions dealing with files will use that "handle" to recognize the open file and refer to it. fread() uses it, fclose() uses it. When dealing with files, directories, or MySQL queryies you will run across this type of variable, often times they are optional.
slk![]()
re·dux (adj.): brought back; returned. used postpositively
[latin : re-, re- + dux, leader; see duke.]
WaSP Accessibility Task Force Member
splintered.co.uk | photographia.co.uk | redux.deviantart.com


I knew someone would beat me to it..dang it!![]()
Last edited by s|k; May 3, 2002 at 07:38.
your post was more accurate though...i didn't use the word "handle" anywhere in my sentence![]()
re·dux (adj.): brought back; returned. used postpositively
[latin : re-, re- + dux, leader; see duke.]
WaSP Accessibility Task Force Member
splintered.co.uk | photographia.co.uk | redux.deviantart.com


So, what is a "handle/pointer" you say?
if you echo( $fp ) you'll get something like Resource ID #1
So when you write:
$fp = fopen("Yadda", w+);
the PHP engine assigns the returned value i.e. the Resource id, of your fopen() call to $fp.
Later when you use $fp in the engine knows exactly where to go to perfome the requested action.
Or that's how I understand it.
Please correct me if I'm wrong.
Pete


okay, feel a little bit better, but I didnt mention the pointer part like you didOriginally posted by redux
your post was more accurate though...i didn't use the word "handle" anywhere in my sentence![]()
which he's gonna need to know about if he wants to read his files more than once in a script
![]()
Last edited by s|k; May 3, 2002 at 07:57.




I am actually slogging my way through a book which I had been told was for beginners. They just tend to leave the explainations of things out a bit. (keep saying how if i know c++ then it should be familiar)
pity I don't know anything but a bit of html
![]()
In this case I was trying to work out why they named the variable $fp and not something else.
thanks for the answers though
they helped .. sort of
![]()
coiL
"cradled in the learning curve"


hehehe, I 'm never answering another one of these threads again
kidding![]()




ok so fp pretty much stands for File pointer
so what is a file pointer?
coiL
"cradled in the learning curve"


Remember it can be anything, $fp just happens to be the example here.
You could say something like:
$AnnaKournikova = fopen("How to date a hockey player in violation of the Mann act.txt", r);
The pointer/handle part is PHP's way of identifying the file in the fopen() call, or fread(), or fwrite().


$fp should be renamed to $RTFMOriginally posted by coiL
ok so fp pretty much stands for File pointer
so what is a file pointer?


okay, a file pointer does two things. One it lets the script know which open file you are talking about. But it also has the second function of letting the script no what part of the file you are at in reading it.
say for instance this imaginary contents of a textfile:
This is a line of text in a text file.
This is a second line of text in a text file.
when you first open the file the file pointer is at the beginning of the text. When you read the file line by line, after reading the first line your filepointer is now at the beginning of the second line. If you want to re-read the first line you have to rewind using a function you'll have to lookup to return to the beginning of the text(hint: it "REWINDS"). If you read the secondline next, the file pointer will now be at the end of the file. You can also use fseek() which will look for text and move your filepointer there.
Am I making sense? Am I wrong? Am I being too nice?
yes you are... no you aren't i guess... and no you're not being too niceOriginally posted by s|k
Am I making sense? Am I wrong? Am I being too nice?![]()
Bookmarks