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

"new line" Character in Single-Quoted Strings in PHP
Can You Specify the "new line" Character in Single-Quoted Strings? You can not specify the "new line" character in a single-quoted string. If you don't believe, try this script: &lt;?php echo '\n will not work in single quoted strings.'; ?&gt; This script will print: \n will not work in sing...
2016-10-13, 2937🔥, 0💬

Copying Array Values to a List of Variables in PHP
How To Copy Array Values to a List of Variables in PHP? If you want copy all values of an array to a list of variable, you can use the list() construct on the left side of an assignment operator. list() will only take values with integer keys starting from 0. Here is a PHP script on how to use list(...
2017-01-29, 2920🔥, 0💬

Truncating an Array in PHP
How To Truncate an Array in PHP? If you want to remove a chunk of values from an array, you can use the array_splice($array, $offset, $length) function. $offset defines the starting position of the chunk to be removed. If $offset is positive, it is counted from the beginning of the array. If negativ...
2017-01-05, 2836🔥, 0💬

Comparing Two Strings with strcmp() in PHP
How To Compare Two Strings with strcmp()? PHP supports 3 string comparison operators, &lt;, ==, and &gt;, that generates Boolean values. But if you want to get an integer result by comparing two strings, you can the strcmp() function, which compares two strings based on ASCII values of their...
2016-10-13, 2752🔥, 0💬

Creating Your Own Functions in PHP
Where to find tutorials on how to create Your Own Functions in PHP? A collection of tutorials to answer many frequently asked questions on Creating Your Own Functions in PHP. Topics included in this collection are: Defining a User Function in PHP Invoking a User Function in PHP Returning a Value fro...
2016-12-28, 2733🔥, 0💬

Accessing a Specific Character in String in PHP
How To Access a Specific Character in a String? Any character in a string can be accessed by a special string element expression: $string{index} - The index is the position of the character counted from left and starting from 0. Here is a PHP script example: &lt;?php $string = 'It\'s Friday!'; e...
2016-10-13, 2709🔥, 0💬

Testing the strpos() Return Value in PHP
What Is the Best Way to Test the strpos() Return Value? Because strpos() could two types of values, Integer and Boolean, you need to be careful about testing the return value. The best way is to use the "Identical(===)" operator. Do not use the "Equal(==)" operator, because it does not differentiate...
2016-10-13, 2704🔥, 0💬

Ways to Remove Leading and Trailing White Spaces in PHP
How Many ways to Remove Leading and Trailing White Spaces? There are 4 PHP functions you can use remove white space characters from the beginning and/or the end of a string: trim() - Remove white space characters from the beginning and the end of a string. ltrim() - Remove white space characters fro...
2016-10-13, 2630🔥, 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...
2023-03-01, 2613🔥, 1💬

Index of Array Values in PHP
How Values in Arrays Are Indexed in PHP? Values in an array are all indexed their corresponding keys. Because we can use either an integer or a string as a key in an array, we can divide arrays into 3 categories: Numerical Array - All keys are sequential integers. Associative Array - All keys are st...
2017-02-03, 2557🔥, 0💬

Cookie Files Stored on Your Computer in PHP
Where Are the Persistent Cookies Stored on Your Computer in PHP? The location and file names where persistent cookies are stored on your computer depend on which browser you are using. If you using Microsoft Internet Explorer, persistent cookies are stored in the \Documents and Settings\$user\Cookie...
2016-11-02, 2551🔥, 0💬

Defining an Array Argument as Reference in PHP
Can You Define an Array Argument as a Reference Type? in PHP? You can define an array argument as a reference type in the function definition. This will automatically convert the calling arguments into references. Here is a PHP script on how to define an array argument as a reference type: &lt;?...
2016-12-18, 2530🔥, 0💬

Converting Strings to Hex Numbers in PHP
How To Convert Strings to Hex Numbers? If you want convert a string into hex format, you can use the bin2hex() function. Here is a PHP script on how to use bin2hex(): &lt;?php $string = "Hello\tworld!\n"; print($string."\n"); print(bin2hex($string)."\n"); ?&gt; This script will print: Hello ...
2016-10-13, 2488🔥, 0💬

Quoting Date and Time Values in PHP
How To Quote Date and Time Values in SQL Statements in PHP? If you want to provide date and time values in a SQL statement, you should write them in the format of "yyyy-mm-dd hh:mm:ss", and quoted with single quotes ('). The tutorial exercise below shows you two INSERT statements. The first one uses...
2016-10-19, 2438🔥, 0💬

What Is a Persistent Cookie in PHP
What Is a Persistent Cookie in PHP? A persistent cookie is a cookie which is stored in a cookie file permanently on the browser's computer. By default, cookies are created as temporary cookies which stored only in the browser's memory. When the browser is closed, temporary cookies will be erased. Yo...
2016-11-04, 2404🔥, 0💬

What Is a Result Set Object in PHP
What Is a Result Set Object in PHP? A result set object is a logical representation of data rows returned by mysql_query() function on SELECT statements. Every result set object has an internal pointer used to identify the current row in the result set. Once you get a result set object, you can use ...
2016-10-20, 2402🔥, 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, 2397🔥, 0💬

Supporting Hidden Form Fields in PHP
How To Support Hidden Form Fields in PHP? Hidden fields are special fields in a form that are not shown on the Web page. But when the form is submitted, values specified in the hidden fields are also submitted to the Web server. A hidden field can be specified with the &lt;INPUT TYPE=HIDDEN ...&...
2016-11-08, 2395🔥, 0💬

Removing Leading and Trailing Spaces in PHP
How To Remove Leading and Trailing Spaces from User Input Values? If you are taking input values from users with a Web form, users may enter extra spaces at the beginning and/or the end of the input values. You should always use the trim() function to remove those extra spaces as shown in this PHP s...
2016-10-13, 2369🔥, 0💬

Working with MySQL Database in PHP
Where to find tutorials on how to work with MySQL Database in PHP? A collection of tutorials to answer many frequently asked questions on how to Work with MySQL Database in PHP. Clear explanations and tutorial exercises are provided on connecting and selecting MySQL database, creating and dropping t...
2016-10-22, 2351🔥, 0💬

Uploading Files into Database in PHP
How To Upload Files into Database in PHP? To store uploaded files to MySQL database, you can use the normal SELECT statement as shown in the modified processing_uploaded_files.php listed below: &lt;?php $con = mysql_connect("localhost", "", ""); mysql_select_db("fyi"); $error = $_FILES['fyicente...
2017-02-20, 2327🔥, 1💬

💬 2017-02-20 Jonas: Thanks for the sample code!

Connecting to a MySQL Server in PHP
How To Connect to MySQL from a PHP Script in PHP? If you want access the MySQL server, you must create a connection object first by calling the mysql_connect() function in the following format: $con = mysql_connect($server, $username, $password); If you are connecting to a local MySQL server, you do...
2016-10-20, 2317🔥, 0💬

Returning an Array from a Function in PHP
How To Return an Array from a Function? in PHP? You can return an array variable like a normal variable using the return statement. No special syntax needed. Here is a PHP script on how to return an array from a function: &lt;?php function powerBall() { $array = array(rand(1,55), rand(1,55), ran...
2016-12-18, 2282🔥, 0💬

PHP Built-in Functions for Arrays
Where to find tutorials on how to use PHP built-in functions to manage arrays? A collection of tutorials to answer many frequently asked questions on how to PHP functions to manage arrays. Clear answers are provided with tutorial exercises on searching keys and values, sorting arrays, merging two ar...
2017-01-29, 2240🔥, 0💬

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