downloads | documentation | faq | getting help | mailing lists | licenses | wiki | reporting bugs | php.net sites | links | conferences | my php.net

search for in the

fgetcsv> <fflush
Last updated: Fri, 30 Oct 2009

view this page in

fgetc

(PHP 4, PHP 5)

fgetc Liest das Zeichen, auf welches der Dateizeiger zeigt

Beschreibung

string fgetc ( resource $handle )

Gibt einen String zurück, welcher ein einzelnes Zeichen von der aktuellen Position des Dateizeigers handle enthält. Gibt FALSE zurück, wenn der Dateizeiger am Ende der Datei steht (wie die Funktion feof()).

Der Dateizeiger muss gültig sein, d.h. die Datei, auf die gezeigt wird, muss zuvor mit fopen(), popen() oder fsockopen() geöffnet worden sein.

Hinweis: Diese Funktion ist "binary safe".

Siehe auch fread(), fopen(), popen(), fsockopen() und fgets().



add a note add a note User Contributed Notes
fgetc
alex at alexdemers dot me
11-May-2009 07:30
The best and simplest way to get input from a user in the CLI with only PHP is to use fgetc() function with the STDIN constant:

<?php

echo 'Are you sure you want to quit? (y/n) ';
$input = fgetc(STDIN);

if (
$input == 'y')
{
    exit(
0);
}

?>
ktraas at gmail dot com (Kevin Traas)
24-Mar-2009 04:08
I was using command-line PHP to create an interactive script and wanted the user to enter just one character of input - in response a Yes/No question.  Had some trouble finding a way to do so using fgets(), fgetc(), various suggestions using readline(), popen(), etc.  Came up with the following that works quite nicely:

$ans = strtolower( trim( `bash -c "read -n 1 -t 10 ANS ; echo \\\$ANS"` ) );

fgetcsv> <fflush
Last updated: Fri, 30 Oct 2009
 
 
show source | credits | sitemap | contact | advertising | mirror sites