1 2 3 4 5 6 > >>   Sort: Rank

Opening a File for Writing in PHP
How To Open a File for Writing in PHP? If you want to open a new file and write date to the file, you can use the fopen($fileName, "w") function. It creates the specified file, and returns a file handle. The second argument "w" tells PHP to open the file for writing. Once the file is open, you can u...
2016-12-02, 179👍, 0💬

Appending Data to the End of a File in PHP
How To Append New Data to the End of a File in PHP? If you have an existing file, and want to write more data to the end of the file, you can use the fopen($fileName, "a") function. It opens the specified file, moves the file pointer to the end of the file, and returns a file handle. The second argu...
2016-12-02, 181👍, 0💬

Reading One Character from a File in PHP
How To Read One Character from a File in PHP? If you have a text file, and you want to read the file one character at a time, you can use the fgetc() function. It reads the current character, moves the file pointer to the next character, and returns the character as a string. If end of the file is r...
2016-12-02, 177👍, 0💬

Reading One Line of Text from a File in PHP
How To Read One Line of Text from a File in PHP? If you have a text file with multiple lines, and you want to read those lines one line at a time, you can use the fgets() function. It reads the current line up to the "\n" character, moves the file pointer to the next line, and returns the text line ...
2016-12-02, 176👍, 0💬

Opening a file for Reading in PHP
How To Open a File for Reading in PHP? If you want to open a file and read its contents piece by piece, you can use the fopen($fileName, "r") function. It opens the specified file, and returns a file handle. The second argument "r" tells PHP to open the file for reading. Once the file is open, you c...
2016-12-02, 175👍, 0💬

Writing an Array to a File without File Handle in PHP
How To Write an Array to a File without a File Handle in PHP? If you have an array, want to write it to a file, and you don't want to open the file with a file handle, you can use the file_put_contents(). It opens the specified file, writes all values from the specified string, closes the file, and ...
2016-11-27, 192👍, 0💬

Writing a String to a File without a File Handle in PHP
How To Write a String to a File without a File Handle in PHP? If you have a string, want to write it to a file, and you don't want to open the file with a file handle, you can use the file_put_contents(). It opens the specified file, writes the specified string, closes the file, and returns the numb...
2016-11-27, 190👍, 0💬

Writing a String to a File with a File Handle in PHP
How To Write a String to a File with a File Handle in PHP? If you have a file handle linked to a file opened for writing, and you want to write a string to the file, you can use the fwrite() function. It will write the string to the file where the file pointer is located, and moves the file pointer ...
2016-11-27, 188👍, 0💬

Issue with "while ($c=fgetc($f))" Loop in PHP
What's Wrong with "while ($c=fgetc($f)) {}" in PHP? If you are using "while ($c=fgetc($f)) {}" to loop through each character in a file, the loop may end in the middle of the file when there is a "0" character, because PHP treats "0" as Boolean false. To properly loop to the end of the file, you sho...
2016-11-27, 187👍, 0💬

Reading a File in Binary Mode in PHP
How To Read a File in Binary Mode in PHP? If you have a file that stores binary data, like an executable program or picture file, you need to read the file in binary mode to ensure that none of the data gets modified during the reading process. You need to: Open the file with fopen($fileName, "rb")....
2016-11-27, 183👍, 0💬

Working with Directoris and Files in PHP
Where to find tutorials on how to Work with Directories and Files in PHP? A collection of tutorials to answer many frequently asked questions on how to Work with Directories and Files in PHP. Topics included in this collection are: Creating a Directory in PHP Removing an Empty Directory in PHP Remov...
2016-11-24, 206👍, 0💬

Reading Data from Keyboard in PHP
How To Read Data from Keyboard (Standard Input) in PHP? If you want to read data from the standard input, usually the keyboard, you can use the fopen("php://stdin") function. It creates a special file handle linking to the standard input, and returns the file handle. Once the standard input is opene...
2016-11-24, 205👍, 0💬

Opening Standard Output as a File Handle in PHP
How To Open Standard Output as a File Handle in PHP? If you want to open the standard output as a file handle yourself, you can use the fopen("php://stdout") function. It creates a special file handle linking to the standard output, and returns the file handle. Once the standard output is opened to ...
2016-11-24, 205👍, 0💬

Creating a Directory in PHP
How To Create a Directory in PHP? You can use the mkdir() function to create a directory. Here is a PHP script example on how to use mkdir(): <?php if (file_exists("/temp/download") ){ print("Directory already exists.\n"); } else { mkdir("/temp/download"); print("Directory created.\n"); } ?> T...
2016-11-24, 204👍, 0💬

Removing an Empty Directory in PHP
How To Remove an Empty Directory in PHP? If you have an empty existing directory and you want to remove it, you can use the rmdir(). Here is a PHP script example on how to use rmdir(): <?php if (file_exists("/temp/download") ){ rmdir("/temp/download"); print("Directory removed.\n"); } else { prin...
2016-11-24, 202👍, 0💬

Reading Directory Entries in PHP
How To Read a Directory One Entry at a Time in PHP? If you want to read a directory one entry at a time, you can use opendir() to open the specified directory to create a directory handle, then use readdir() to read the directory contents through the directory handle one entry at a time. readdir() r...
2016-11-20, 222👍, 0💬

Copying a File in PHP
How To Copy a File in PHP? If you have a file and want to make a copy to create a new file, you can use the copy() function. Here is a PHP script example on how to use copy(): <?php unlink("/temp/myPing.exe"); copy("/windows/system32/ping.e xe","/temp/myPing.exe"); if (file_exists("/temp/myPing.e.. .
2016-11-20, 214👍, 0💬

Removing a File in PHP
How To Remove a File in PHP? If you want to remove an existing file, you can use the unlink() function. Here is a PHP script example on how to use unlink(): <?php if (file_exists("/temp/todo.txt") ){ unlink("/temp/todo.txt"); print("File removed.\n"); } else { print("File does not exist.\n"); } ?...
2016-11-20, 207👍, 0💬

Retrieving Directory Name from File Path Name in PHP
How To Get the Directory Name out of a File Path Name in PHP? If you have the full path name of a file, and want to get the directory name portion of the path name, you can use the dirname() function. It breaks the full path name at the last directory path delimiter (/) or (\), and returns the first...
2016-11-20, 206👍, 0💬

Putting Directory Entries into an Array in PHP
How To Dump the Contents of a Directory into an Array in PHP? If you want to get the contents of a directory into an array, you can use the scandir() function. It gets a list of all the files and sub directories of the specified directory and returns the list as an array. The returning list also inc...
2016-11-20, 201👍, 0💬

Creating a Web Form in PHP
How To Create a Web Form in PHP? If you take input data from visitors on your Web site, you can create a Web form with input fields to allow visitors to fill in data and submit the data to your server for processing. A Web form can be created with the <FORM> tag with some input tags. The <F...
2016-11-17, 226👍, 0💬

Processing Web Forms in PHP
Where to find tutorials on how to process Web Forms in PHP? A collection of tutorials to answer many frequently asked questions on how to process Web Forms in PHP. Clear explanations and tutorial exercises are provided on generating and processing Web forms, getting values out of $_REQUEST, processi...
2016-11-17, 223👍, 0💬

Form Input HTML Tags in PHP
What Are Form Input HTML Tags in PHP? HTML tags that can be used in a form to collect input data are: <SUBMIT ...> - Displayed as a button allow users to submit the form. <INPUT TYPE=TEXT ...> - Displayed as an input field to take an input string. <INPUT TYPE=RADIO ...> - Displayed...
2016-11-17, 219👍, 0💬

Generating a Form in PHP
How To Generate a Form in PHP? Generating a form seems to be easy. You can use PHP output statements to generate the required <FORM> tag and other input tags. But you should consider to organized your input fields in a table to make your form looks good on the screen. The PHP script below show...
2016-11-17, 213👍, 0💬

1 2 3 4 5 6 > >>   Sort: Rank