<< < 2 3 4 5 6 7 8 9 10 11 12 > >>   Sort: Rank

Function Returns Data by Value in PHP
How Values Are Returned from Functions? in PHP? If a value is returned from a function, it is returned by value, not by reference. That means that a copy of the value is return. Here is a PHP script on how values are returned from a function: <?php $favor = "vbulletin"; function getFavor() { glob...
2016-12-08, 307👍, 0💬

Global Variables in Main Script in PHP
What Is the Scope of a Variable Defined outside a Function? in PHP? A variable defined outside any functions in main script body is called global variable. However, a global variable is not really accessible globally any in the script. The scope of global variable is limited to all statements outsid...
2016-12-08, 279👍, 0💬

Specifying Argument Default Values in PHP
How To Specify Argument Default Values? in PHP? If you want to allow the caller to skip an argument when calling a function, you can define the argument with a default value when defining the function. Adding a default value to an argument can be done like this "function name($arg=expression){}. Her...
2016-12-04, 461👍, 0💬

Reading and Writing Files in PHP
Where to find tutorials on how to Read and Write Files in PHP? A collection of tutorials to answer many frequently asked questions how to Read and Write Files in PHP. Topics included in this collection are: Reading a Text File to an Array in PHP Reading the Entire File to a String in PHP Opening a f...
2016-12-04, 447👍, 0💬

Reading the Entire File to a String in PHP
How To Read the Entire File into a Single String in PHP? If you have a file, and you want to read the entire file into a single string, you can use the file_get_contents() function. It opens the specified file, reads all characters in the file, and returns them in a single string. Here is a PHP scri...
2016-12-04, 287👍, 0💬

Reading a Text File to an Array in PHP
How To Read a Text File into an Array in PHP? If you have a text file with multiple lines, and you want to read those lines into an array, you can use the file() function. It opens the specified file, reads all the lines, puts each line as a value in an array, and returns the array to you. Here is a...
2016-12-04, 283👍, 0💬

Function with Undefined Number of Arguments in PHP
How To Define a Function with Any Number of Arguments? in PHP? If you want to define a function with any number of arguments, you need to: Declare the function with no argument. Call func_num_args() in the function to get the number of the arguments. Call func_get_args() in the function to get all t...
2016-12-04, 274👍, 0💬

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, 310👍, 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, 315👍, 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, 277👍, 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, 276👍, 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, 272👍, 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, 403👍, 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, 325👍, 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, 318👍, 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, 316👍, 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, 275👍, 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, 445👍, 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, 421👍, 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, 308👍, 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, 307👍, 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, 252👍, 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, 286👍, 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, 280👍, 0💬

<< < 2 3 4 5 6 7 8 9 10 11 12 > >>   Sort: Rank