<< < 1 2 3 4 5 6 7 8 > >>   Sort: Date

Selecting an Existing Database in PHP
How To Select an Exiting Database in PHP? The first thing after you have created a connection object to the MySQL server is to select the database where your tables are locate, by using the mysql_select_db() function. If your MySQL server is offered by your Web hosting company, they will assign a da...
2016-10-20, 2185🔥, 0💬

Viewing the Content of a Cookie File in PHP
How to View the Content of a Cookie File in PHP? Cookie files are normal text files. You can view them with any text editor. Follow the steps below to see what is in a cookie file created by your own PHP script. Copy the following sample script, setting_persistent_cookies.php ,to your Web server: &a...
2016-10-30, 2147🔥, 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(): &lt;?php if (file_exists("/temp/download") ){ print("Directory already exists.\n"); } else { mkdir("/temp/download"); print("Directory created.\n"); } ?&a...
2016-11-24, 2146🔥, 0💬

Setting a Persistent Cookie in PHP
How To Set a Persistent Cookie in PHP? If you want to set a persistent cookie, you can use the setcookie() function with an extra parameter to specify its expiration time. To follow sample script sets 2 persistent cookies to be expired within 7 days: setcookie("LoginName","FYICent er");setcookie("Pr...
2016-11-04, 2122🔥, 0💬

Setting session.gc_maxlifetime Properly in PHP
How To Set session.gc_maxlifetime Properly in PHP? As you know that session.gc_maxlifetime is the session value timeout period. You should set this value based on the usage pattern of your visitors. Here are some suggestions: # Set it to 20 minutes for a normal Web site: session.gc_maxlifetime = 120...
2016-10-24, 2122🔥, 0💬

Creating a Database Table to Store Files in PHP
How To Create a Table To Store Files in PHP? If you using MySQL database and want to store files in database, you need to create BLOB columns, which can holds up to 65,535 characters. Here is a sample script that creates a table with a BLOB column to be used to store uploaded files: &lt;?php $co...
2016-10-14, 2110🔥, 0💬

Filtering Out Empty Files in PHP
Why Do You Need to Filter Out Empty Files in PHP? When you are processing uploaded files, you need to check for empty files, because they could be resulted from a bad upload process but the PHP engine could still give no error. For example, if a user typed a bad file name in the upload field and sub...
2016-10-14, 2108🔥, 0💬

Using an Array as a Stack in PHP
How To Use an Array as a Stack in PHP? A stack is a simple data structure that manages data elements following the first-in-last-out rule. You use the following two functions together to use an array as a stack: array_push($array, $value) - Pushes a new value to the end of an array. The value will b...
2017-01-11, 2103🔥, 0💬

Copying an Array in PHP
Can You Copy an Array in PHP? You can create a new array by copying an existing array using the assignment statement. Note that the new array is not a reference to the old array. If you want a reference variable pointing to the old array, you can use the reference operator "&amp;". Here is a PHP...
2017-02-03, 2075🔥, 0💬

Supporting a Multiple-Page Form in PHP
How To Support Multiple-Page Forms in PHP? If you have a long form with a lots of fields, you may want to divide the fields into multiple groups and present multiple pages with one group of fields on one page. This makes the a long form more user-friendly. However, this requires you to write good sc...
2016-11-05, 2063🔥, 0💬

Joining Keys and Values into an Array in PHP
How To Join a List of Keys with a List of Values into an Array in PHP? If you have a list keys and a list of values stored separately in two arrays, you can join them into a single array using the array_combine() function. It will make the values of the first array to be the keys of the resulting ar...
2017-01-11, 2060🔥, 0💬

Data Types of Array Keys in PHP
What Types of Data Can Be Used as Array Keys in PHP? Two types of data can be used as array keys: string and integer. When a string is used as a key and the string represent an integer, PHP will convert the string into a integer and use it as the key. Here is a PHP script on different types of keys:...
2017-02-03, 2050🔥, 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, 2008🔥, 0💬

Running a PHP Script
How To Run a PHP Script? A standard alone PHP script can be executed directly with the PHP Command Line Interface (CLI). Write the following script in a file called hello.php: &lt;?php echo "Hello world!"; ?&gt; This script can be executed by CLI interface like this: \php\php hello.php You s...
2016-10-13, 2006🔥, 0💬

Downloading and Installing PHP
Where to find tutorials in downloading and installing PHP binary version for Windows system. Here is a list of tutorials to answer many frequently asked questions compiled by FYIcenter.com team in downloading and installing PHP binary version for Windows system. Installing PHP for Windows Verifying ...
2016-10-13, 2000🔥, 0💬

Generating and Processing Form with the Same Script in PHP
How To Generate and Process a Form with the Same Script in PHP? In previous exercises, a Web form is generated by one script, and processed by another script. But you could write a single script to do both. You just need to remember to: Use same script name as the form generation script in the "acti...
2016-11-08, 1982🔥, 0💬

Counting the Number of Characters in PHP
How To Count the Number of Characters in a String? You can use the "strlen()" function to count the number of characters in a string. Here is a PHP script example of strlen(): &lt;?php print(strlen('It\'s Friday!')); ?&gt; This script will print: 12     ⇒ Ways to Remove Leading and Trailing...
2016-10-13, 1979🔥, 0💬

Generating Character from ASCII Value in PHP
How To Generate a Character from an ASCII Value? If you want to generate characters from ASCII values, you can use the chr() function. chr() takes the ASCII value in decimal format and returns the character represented by the ASCII value. chr() complements ord(). Here is a PHP script on how to use c...
2016-10-13, 1951🔥, 0💬

Installing PHP for Windows
How To Download and Install PHP for Windows? The best way to download and install PHP on Windows systems is to: Go to http://www.php.net, which is the official Web site for PHP. Download PHP binary version for Windows in ZIP format. Unzip the downloaded file into a directory. You are done. No need t...
2016-10-13, 1932🔥, 0💬

Remove Trailing New Line Character in PHP
How To Remove the New Line Character from the End of a Text Line? If you are using fgets() to read a line from a text file, you may want to use the chop() function to remove the new line character from the end of the line as shown in this PHP script: &lt;?php $handle = fopen("/tmp/inputfile.txt"...
2016-10-13, 1919🔥, 0💬

Retrieving All Values from an Array in PHP
How To Get All the Values Out of an Array in PHP? Function array_values() returns a new array that contains all the values of a given array. Here is a PHP script on how to use array_values(): &lt;?php $mixed = array(); $mixed["Zero"] = "PHP"; $mixed[1] = "Perl"; $mixed["Two"] = "Java"; $mixed["3...
2017-01-21, 1918🔥, 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, 1893🔥, 0💬

Single Cookie Size Limit in PHP
How Large Can a Single Cookie Be in PHP? How large can a single cookie be? The answer is depending what is the Web browser your visitor is using. Each browser has its own limit: Internet Explorer (IE): about 3904 bytes Mozilla Firefox: about 3136 bytes If you want to test this limit, copy this sampl...
2016-10-30, 1876🔥, 0💬

Returning a Reference from a Function in PHP
How To Return a Reference from a Function? in PHP? To return a reference from a function, you need to: Add the reference operator "&amp;" when defining the function. Add the reference operator "&amp;" when invoking the function. Here is a PHP script on how to return a reference from a functi...
2016-12-08, 1864🔥, 0💬

<< < 1 2 3 4 5 6 7 8 > >>   Sort: Date