pointer of the file to the starting position of the file: no return value.
3. A. rewind (fp); after the command is executed, the position pointer of the file is located at the beginning of the file.
Random read/write: changes the position pointer of a file, which is generally used for binary files.
Fseek (file type pointer, displacement, starting point); no return value.
Start Point: SEEK_SET 0 at the beginning of the file
Current File Location SEEK_
Six pre-defined interfaces in PHP
This article mainly introduces six pre-defined interfaces in PHP. This article describes Traversable, Iterator, IteratorAggregate, ArrayAccess, Serializable, and Closure. For more information, see
PHP predefines six interfaces as follows:
1. Traversable traversal Interface
Haha! In fact, it is not an interface that can be used in PHP, and internal classes can be used. It has a purpose to detect whether a class can be traversed.
?
1 2 3
If ($
position. The position is always between 0 and bounds.Buffer flagsThe tag is similar to setting a bookmark to a buffer. The current position is recorded when you call Mark (), and the position of the marker when you call Reset () is restored.Buffer flip, clear, and rewindBuffer Flip ()The flip () method is used to prepare the buffer for a get operation or to prepare a new write sequence. Flip () Sets the bounds to the current position and then positions the position to 0.Buffer Clear ()The clea
current index cursor Abstract public scalar key (void) // Move the current index cursor to the next element Abstract public void next (void) // Reset the index cursor pointing to the first element Abstract public void rewind (void) // Determines whether the current index cursor points to an element. it is often used when rewind () or next () is called. Abstract public boolean valid (void) }
The a
through the pickup head, or the sound waveform on the tape is detected and played back to the audience.In addition to playing the tape forward, you can also rewind the tape back to the previous section, or skip over the back part.Imagine the band recording tapes in the 70 's. You can imagine them practicing songs over and over, until all the parts are perfect and then recorded on the track. At first, you'll record the drums, then the bass, then the g
Code
$mulu = "study";$dir =opendir ($mulu);Closedir ($dir);?>
Using the function Closedir () to close a directory successfully does not return a value of 1, so the IF statement cannot be used to determine whether the closure succeeds
This article introduces a series of PHP file operations, and then the author introduces how to operate the directory. PHP directory function function is similar to the file function, here first introduced the Open Directory function Opend
); if(!feof($fp)){ echo ($char == "\n "? " ": $char); }}
Read arbitrary length: f
Read ()
The last way to read a file is to use the fread () function to read any length of bytes from the file.
Check whether the file exists:
File_exists ()
Determine the file size:
Filesize ()
Delete an object:
Unlink ()(PHP does not have a function named delete)
Locate in the file:
Rewind (),
Fseek ()And
Ftell ()
Command modeDefinition: A command pattern encapsulates a request or action into an object. The command mode allows the system to parameterize the client using different requests, queue requests, or log request logs, which can provide undo and redo functions for the command.Code: (Take recorder as an example)Sound Recorder Class: Concrete method realization Public class Audioplayer { publicvoid play () { System.out.println ("Play ..."); } Public void
("% d", ferror (FP ));
12. Rewind ()Return the current read/write location to the start of the file. The prototype is void rewind (File * stream). In fact, this function is equivalent to fseek (FP, 0l, seek_set );
Example: rewind (FP );
12. Remove ()Delete the file. The prototype is int remove (const char * filename). The parameter is the name of the file t
; + } - return 0; +}The fwrite function can put multiple variables in the array at once in binary mode (binary write on Unix system and text write no difference, if written as text on the Windows system will write a newline character \ r \ n, accounting for two bytes) to the file, The return value indicates the number of variables written.The Fread function can read the values of multiple variables from a file in binary mode at once and record them in an array, and the return value repre
::iswritable
Returns true if the file is writable
Directoryiterator::key
Returns the current directory entry
Directoryiterator::next
Move to the next item
Directoryiterator::rewind
Return the directory pointer to the start position
Directoryiterator::valid
Check if the directory contains more items
In addition, the method of processing directories in the SPL class library has
Introduction to 6 predefined interfaces in PHP
This article mainly introduces the 6 predefined interfaces introduced in PHP, this article explains Traversable, Iterator, Iteratoraggregate, arrayaccess, Serializable, Closure, A friend you need can refer to the following
PHP pre-defined 6 interfaces are described below:
1.Traversable Traversal Interface
Actually, it is not an interface that can be used in PHP, the inner class can be used, and it has a purpose of detecting whether a class can trav
file type}Closedir ($DH); Close a directory handle}}
///
if ($handle =opendir (' web '))///If the directory is opened successfully{while ($file =readdir ($handle))//Iterate through the entries in the directory false!=={if ($file!= "." $file!= "...") If the file is not current or parent directory{echo "$filen"; Output file name}}Closedir ($handle); Close a directory handle}
//
if ($handle =opendir (' 08 '))//If the directory is opened successfully{while ($file =readdir ($handle))//Iterate th
($ filename, "r ");If ($ w1) echo fgets ($ file);/* read file content */Else echo "writing failed ";}Else echo "file not writable ";?>
The php pointer function rewind () can set the file position pointer to the beginning of the file. its structure is as follows:
Bool rewind (resource $ handle );
The function returns a boolean value. if the operation succeeds, true is returned. if the operation fails
data flow. We just write the data and read it to the end of the stream to consume it.We're going to use stream to do these--familiar areas, and then we re-implement it with pipelines to see similarities and differences, and after that we'll look at what's going on inside of it, and then we can see why it attracts us.You might say, "Ah, I remember TextReader / TextWriter " I deliberately don't use them--because I'm here trying to talk about the stream API, so our example can be extended to a wid
['routestring']); if (count($routeInfo)
The requested ajax/api/hook/decodeArguments will instantiate the hook class and then call the decodeArguments () function. The trigger point mentioned in the original text is here:
public function decodeArguments($arguments){ if ($args = @unserialize($arguments)) { $result = ''; foreach ($args AS $varname => $value) { $result .= $varname;
Through deserialization, we can generate a class instance that has been
:• Skimagedecoder_factory.cpp• Skimageencoder_factory.cppThe preceding two files define the following two important functions:
SkImageDecoder* SkImageDecoder::Factory(SkStream* stream) { SkImageDecoder* codec = NULL; const DecodeReg* curr = DecodeReg::Head(); while (curr) { codec = curr->factory()(stream); // we rewind here, because we promise later when we call "decode", that // the stream will be at its beginning.
returned. This can be used to determine the write operator, write a file, and read the file content and display it on the screen.
# Include
Main ()
{
File * FP;
Char ch;
If (FP = fopen ("d :\\ jrzh \ example \ string", "WT +") = NULL)
{
Printf ("cannot open file strike any key exit! ");
Getch ();
Exit (1 );
}
Printf ("input a string: \ n ");
Ch = getchar ();
While (Ch! = '\ N ')
{
Fputc (CH, FP );
Ch = getchar ();
}
Rewind (FP );
Ch = fgetc (FP );
W
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.