Category:php functions

Google Custom Search

How to use parse_str()

parse_str(string $str [,array &$arr ])


$string = 'firstVar=first&secondVar=second&thirdVar=third';


echo $firstVar; // outputs first

echo firstVar; // outputs second

echo firstVar; // outputs third


The pars_str() php function converts the string variables into php variables with the same name that the string variable was . This is very useful for parameters that are passed via a URL string. Url arguments begin after the "?". Each variable is separated using the "&" character.

Author: D.Shaun Morgan

Ob Start

How to Use ob_start() - PHP8/12/2014bool ob_start ([ callback $output_callback [, int $chunk_size [, bool $erase ]]] )ob_start holds everything except for headers on a webpage - i.e the whole script, html, etcetera in an internal memory buffer until either the script reaches the end of tile or the script reaches ob_end_flush().ob_end_flush() Outputs Stored Bufferob_end_flush() outputs what is stored in the bu

Str Ireplace

mixed str_ireplace ( mixed $search , mixed $replace , mixed $subject [, int &$count ] ) Str_ireplace() searches and replaces text found in php strings and variables. Str_ireplace() is used for reformatting documents on the fly, making last minute fixes, and injecting new content into a document.This example of str_ireplace() reads the name of the pages here on and performs a series of string replacements in order to create the anchor texts that are


rtrimRemoves whitespace from the right side of a stringSeetrim()ltrim()


chop() PHP Functionchop() is identical to the rtrim function string rtrim(string $str[, string $charlist ])Strips characters including hex characters and hidden chars from the right most position in a string.Default strips" " (ASCII 32 (0x20)), an ordinary space. "\t" (ASCII 9 (0x09)), a tab. "" (ASCII 10 (0x0A)), a new line (line feed). "\r" (ASCII 13 (0x0D)), a carriage re

Array Rand

array_rand(array $input [, int $num_req= 1 ])ReturnsRandom keyArgumentsArgument 1 is an array. Arguments 2 is an integer that determines how many keys will be returnedThe script below uses the random function to shuffle around the array indexes in content; then it transfers the values of those indices into a $temp variable. Next the content variable is destroyed and created again, and for clarity in the script, the $temp variable's v

File Get Contents

file_get_contents PHP Functionfile_get_contents() streams in the content of a files that is passed to it as an argument.<?php$x = file_get_contents('testFile.txt);echo $x;?>The example above will print out whatever was stored in testFile.txt

Strip Tags

StripTags() php function Striptags() is a php function that literally strips HTML tags out of files that are streamed in to php with a function like file_get_contents()<?php$x = file_get_contents(''test_file.html'); // test_file has <h1> test me now </h1>$x = strip_tags($x)echo $x

Var Dump

var_dump()var_dump() is very useful when you want to know what is inside of a php variable at certain spot in your php script.Arguments Passedvar_dump($variableToInspect)Pass the variable you want to inspect the var_dump function.Returnsvar_dump will return the contents of the variable you passed to it.


The die function Die('') is a very useful php function. You can place "die anywhere in a script that want that script to terminate. It also provides a bit of feedback to help the programmer when he/she needs to figure out where the script was last executing. It is very useful to see if you are down inside of a logic control structure such as an if statement or a case switch.Die takes a string as an argument and re


string addcslashes(string $str , string $charlist)How to use addslashes<?php$SlashedString = 'Myexample';$char_list = 'ea';$StrippedString = addcslashes($exampleString , $char_list);echo $SlashedString;//output will be My\ex\ampl\e?>Related Functions


string ucwords(string $mystring)Takes This function takes a string.Returns Converts every first letter of every word to an upper case letter.The example above will print to screen


trim() - phpTrims off white spaces from the beginning and ending of strings.$text = ' test ';$text =trim($text);echo $text;//gives 'test' with the white spaces gone

Substr Count

How to use substr_count() int substr_count ( string $haystack , string $needle [, int $offset= 0 [, int $length ]] )substr_count ( string $haystack , string $needle [, int $offset= 0 [, int $length ]] ) Is a php function looks for instances of A String Within a String.It returns how many instances are found.The example below is using


strtoupper() - php$str = 'this string is all upper case';echo strtoupper($str); ResultTHIS STRING IS ALL UPPER CASE


stripos - phpone is at the 14th positionEven tho


strpos - phpone is at the 14th positionEven though


strlen($string)Gives the length of string supplied arguments


How to use stripslashes<?php$exampleString = 'My\ex\ampl\e';$charlist = 'ea';$StrippedString = stripslashes( $exampleString);echo $StrippedString;//output will be Myexample?>Related FunctionsAddslas

Str Word Count

str_word_count() phpCounts the numbers of words found in a string.ResultThere are 10 words in $str.

Parse Str

How to use parse_str()parse_str(string $str [,array &$arr ]) <?php$string = 'firstVar=first&secondVar=second&thirdVar=third';parse_str($string);echo $firstVar; // outputs firstecho firstVar; // outputs secondecho firstVar; // outputs third?>The pars_str()


nl2br() - How to convert newline characters to line breaks HTMLTo preserve the layout of characters type into a text-box and format it to display in an HTML documentnl2br() is a handy function.Simply pass into the nl2br function the results of a form that was posted and it returns that same content with the newline and carriage return values replaced by HTML line break tags .


md5() md5 is a mathematical algorithm that is commonly called the md5 digest. The md5 procedure takes alphanumeric input and performs what is known as a hash returning a 128 bit unique sequence of 32 hexadecimal digits. This technique is sometimes used for security reasons - for storing and retrieving passwords, especially on internet websites. One common way to store a person's credentials in an online database is with the md5 hash. When the person subm

Md5 File

How to Use md5_file()php functionmd5 is a mathematical algorithm that is commonly called the md5 digest. The md5 procedure takes alphanumeric input and performs what is known as a hash returning a 128 bit unique sequence of 32 hexadecimal digits. This technique is used for security reasons. You will find cases of it used on the Internet when there is a file that is offered for download, included with the file will be a "hash" value. The idea is to download the file


ltrim ltrim() php functionltrim removes the leftmost entity from a string in PHP." " (ASCII 32 (0x20) - space. "\t" (ASCII 9 (0x09)) - tab. "" (ASCII 10 (0x0A) - (line feed)."\r" (ASCII 13 (0x0D))carriage return."\0" (ASCII 0 (0x00)) - Null Byte."\x0B" (ASCII 11 (0x0B)) - vertical tab.See Alsochop()


how to use implode() php functionThe implode() php function is exactly the opposite of explode(). It takes an array of strings and combines them together returning one single string.$content[0]<p>First paragraph of our example.</p>$content[1]<p>Second paragraph of our example.</p>$content[2]<


Explode()PHP FunctionUsed to read, parse and manipulate website content.Chops text into smaller pieces and places each piece into an array variable. Content Example Stored in Database First paragraph example.Second paragraph example.Third paragraph example.


php echo contentEcho is used in php scripts to output content to the screen. echo is one of the most used functions in the php language.
Google Custom Search

Leave a Comment




Enter The Captcha: