Linux and UNIX Man Pages

Linux & Unix Commands - Search Man Pages

fgetc(3) [php man page]

FGETC(3)								 1								  FGETC(3)

fgetc - Gets character from file pointer

SYNOPSIS
string fgetc (resource $handle) DESCRIPTION
Gets a character from the given file pointer. PARAMETERS
o $handle -The file pointer must be valid, and must point to a file successfully opened by fopen(3) or fsockopen(3) (and not yet closed by fclose(3)). RETURN VALUES
Returns a string containing a single character read from the file pointed to by $handle. Returns FALSE on EOF. Warning This function may return Boolean FALSE, but may also return a non-Boolean value which evaluates to FALSE. Please read the section on Booleans for more information. Use the === operator for testing the return value of this function. EXAMPLES
Example #1 A fgetc(3) example <?php $fp = fopen('somefile.txt', 'r'); if (!$fp) { echo 'Could not open file somefile.txt'; } while (false !== ($char = fgetc($fp))) { echo "$char "; } ?> NOTES
Note This function is binary-safe. SEE ALSO
fread(3), fopen(3), popen(3), fsockopen(3), fgets(3). PHP Documentation Group FGETC(3)

Check Out this Related Man Page

FTELL(3)								 1								  FTELL(3)

ftell - Returns the current position of the file read/write pointer

SYNOPSIS
int ftell (resource $handle) DESCRIPTION
Returns the position of the file pointer referenced by $handle. PARAMETERS
o $handle - The file pointer must be valid, and must point to a file successfully opened by fopen(3) or popen(3). ftell(3) gives undefined results for append-only streams (opened with "a" flag). RETURN VALUES
Returns the position of the file pointer referenced by $handle as an integer; i.e., its offset into the file stream. If an error occurs, returns FALSE. Note Because PHP's integer type is signed and many platforms use 32bit integers, some filesystem functions may return unexpected results for files which are larger than 2GB. EXAMPLES
Example #1 ftell(3) example <?php // opens a file and read some data $fp = fopen("/etc/passwd", "r"); $data = fgets($fp, 12); // where are we ? echo ftell($fp); // 11 fclose($fp); ?> SEE ALSO
fopen(3), popen(3), fseek(3), rewind(3). PHP Documentation Group FTELL(3)
Man Page

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

how to use pipes + redirection to create two files?

# this works # creates two.txt (echo one;echo two;echo three;) | ( ( grep two > two.txt ) ) # wamt this to create two files: # two.txt containing "two" and three.txt containing "three" # Both files get created, but three.txt is empty # is there a way to do this? (echo one;echo two;echo... (3 Replies)
Discussion started by: tphyahoo
3 Replies

2. UNIX for Dummies Questions & Answers

echo is too slow. HELP with Awk

Hello All, Below is a simple script i worte to find the 208th char in a file. If the char = "C" then I re-direct the line to a file called change.txt. If it is not "C" then I re-direct it to a file called delete.txt. My problem is I have a file 0f 500K lines. this script is very slow. I am... (4 Replies)
Discussion started by: eja
4 Replies

3. UNIX for Dummies Questions & Answers

Replacing string

Hi there, I'd like to replace STRING_ZERO in FILE_ZERO.txt with the value of VALUEi-th by using something like that: VALUE1=1000 VALUE2=2000 VALUE3=3000 for((i=1;i<=3;i++)); do sed "s/STRING_ZERO/$VALUE'$i'/" FILE_ZERO.txt >> FILE_NEW.txt; done but it doesn't work... Any help... (9 Replies)
Discussion started by: Giordano Bruno
9 Replies

4. Programming

Adding a single char to a char pointer.

Hello, I'm trying to write a method which will return the extension of a file given the file's name, e.g. test.txt should return txt. I'm using C so am limited to char pointers and arrays. Here is the code as I have it: char* getext(char *file) { char *extension; int i, j;... (5 Replies)
Discussion started by: pallak7
5 Replies

5. Shell Programming and Scripting

extracting value in variable??

Hi in Below example. i want "n = aa.txt.gz" ????????????? plz help m=aa.txt n=echo`gzip $m` echo $n (1 Reply)
Discussion started by: manish.s
1 Replies

6. Shell Programming and Scripting

cat vs head vs readline get variable from txt file

I have a file with a single filename in it, which I want to assign to a BASH variable, so I've been trying: c=$(head -1 somefile) echo $c which outputs correctly, but them when I do ... somecommand $c it says it can't find the file, is that because it's grabbing the whole line, and... (5 Replies)
Discussion started by: unclecameron
5 Replies

7. Programming

fopen() - don't know what I'm doing wrong

This code works fine when I use a command line argument for fopen()'s parameter, but when I change it to a filename, the program freezes upon compilation. input.txt is definitely there, so I can't figure it out. Thanks. #include <stdlib.h> #include <stdio.h> #include <ctype.h> int... (3 Replies)
Discussion started by: lazypeterson
3 Replies

8. HP-UX

Inserting Stinr in between some where in file

Hello Mates, I have one txt file having commo seperated values. I have to insert string "FALSE" in 2nd field from the end. E.G SE18 6RN,,,,5439070,1786840,,1000002148671600,123434 Out put should be: SE18 6RN,,,,5439070,1786840,FALSE,1000002148671600,123434 Can some one help me... (0 Replies)
Discussion started by: krsnadasa
0 Replies

9. Shell Programming and Scripting

Working with lines or variables that have spaces or special characters

Example: while read line do stat -c %G $line done < somefile.txtThe problem is that inside somefile.txt lines can have any symbol allowed as file name, like (). Even with spaces, it splits the words. somefile.txt:dira/my first jump.avi dirb/surf video (1080p).mkv (2 Replies)
Discussion started by: Tribe
2 Replies