php string functions list

String functions php



PHP is reffered as very strong server side scripting language, because of its huge set of in reached functions. There are more than 700 functions in php. PHP really have lots of built in functions, so developer dosen't need to write small snippets for small operations. PHP's function set consists of variety of functions including,

String manuplation functions
Array handling functions
Image processing functions
Mail related functions
Mathematical functions
Functions for XML manuplation

In this post, I am trying to list all the important string function in php.
addcslashes
Quote string with slashes in a C style. "Magicquotes"
Syntax : string addcslashes ( string $str , string $charlist )
bin2hexConvert binary data into hexadecimal representation.
string bin2hex ( string $str )
chopAlias of rtrim(). Remove white spaces from right isde of string.
chrReturn a specific character
chunk_splitSplit a string into smaller chunks
string chunk_split ( string $body [, int $chunklen [, string $end ]] )
convert_cyr_stringConvert from one Cyrillic character set to another
string convert_cyr_string ( string $str , string $from , string $to )
convert_uudecode Decode a uuencoded string
string convert_uudecode ( string $data )
convert_uuencode Uuencode a string
string convert_uuencode ( string $data )
count_chars Return information about characters used in a string
count_chars ( string $string [, int $mode ] )
crc32 Calculates the crc32 polynomial of a string
int crc32 ( string $str )
crypt One-way string encryption (hashing)
echo Output one or more strings
explode

Split a string by string.

Syntax:explode('-','php-freelancer');

Return: array.
More about php explode

fprintf Write a formatted string to a stream
get_html_translation_table Returns the translation table used by htmlspecialchars() and htmlentities()
hebrev Convert logical Hebrew text to visual text
hebrevc Convert logical Hebrew text to visual text with newline conversion
html_entity_decode Convert all HTML entities to their applicable characters
htmlentities Convert all applicable characters to HTML entities
htmlspecialchars_decode Convert special HTML entities back to characters
htmlspecialchars Convert special characters to HTML entities
implode Join array elements with a string
join Alias of implode()
levenshtein Calculate Levenshtein distance between two strings
localeconv Get numeric formatting information
ltrim Strip/remove whitespace (or other characters) from the beginning of a string
md5_file Calculates the md5 hash of a given file
md5 Calculate the md5 hash of a string
metaphone Calculate the metaphone key of a string
money_format Formats a number as a currency string
nl_langinfo Query language and locale information
nl2br Inserts HTML line breaks before all newlines in a string
number_format Format a number with grouped thousands
ord Return ASCII value of character
parse_str Parses the string into variables
print Output a string
printf Output a formatted string
quoted_printable_decode Convert a quoted-printable string to an 8 bit string
quotemeta Quote meta characters
rtrim Strip whitespace (or other characters) from the end of a string
setlocale Set locale information
sha1_file Calculate the sha1 hash of a file
sha1 Calculate the sha1 hash of a string
similar_text Calculate the similarity between two strings
soundex Calculate the soundex key of a string
sprintf Return a formatted string
sscanf Parses input from a string according to a format
str_ireplace Case-insensitive version of str_replace().
str_pad Pad a string to a certain length with another string
str_replace Replace all occurrences of the search string with the replacement string
str_rot13 Perform the rot13 transform on a string
str_shuffle Randomly shuffles a string
str_split Convert a string to an array
str_word_count Return information about words used in a string
strcasecmp Binary safe case-insensitive string comparison
strchr Alias of strstr()
strcmp Binary safe string comparison
strcoll Locale based string comparison
strcspn Find length of initial segment not matching mask
strip_tags Strip HTML and PHP tags from a string
stripcslashes Un-quote string quoted with addcslashes()
stripos Find position of first occurrence of a case-insensitive string
stripslashes Un-quote string quoted with addslashes()
stristr Case-insensitive strstr()
strlen Get string length
strnatcasecmp Case insensitive string comparisons using a "natural order" algorithm
strnatcmp String comparisons using a "natural order" algorithm
strncasecmp Binary safe case-insensitive string comparison of the first n characters
strncmp Binary safe string comparison of the first n characters
strpbrk Search a string for any of a set of characters
strpos Find position of first occurrence of a string
strrchr Find the last occurrence of a character in a string
strrev Reverse a string
strripos Find position of last occurrence of a case-insensitive string in a string
strrpos Find position of last occurrence of a char in a string
strspn Find length of initial segment matching mask
strstr Find first occurrence of a string
strtok Tokenize string
strtolower Make a string lowercase
strtoupper Make a string uppercase
strtr Translate certain characters
substr_compare Binary safe optionally case insensitive comparison of 2 strings from an offset, up to length characters
substr_count Count the number of substring occurrences
substr_replace Replace text within a portion of a string
substr Return part of a string
trim Strip whitespace (or other characters) from the beginning and end of a string
ucfirst Make a string's first character uppercase
ucwords Uppercase the first character of each word in a string
vfprintf Write a formatted string to a stream
vprintf Output a formatted string
vsprintf Return a formatted string
wordwrap Wraps a string to a given number of characters using a string break character

mysql-fetch-assoc-vs-mysql-fetch-array

What is the difference between mysql_fetch_assoc() and mysql_fetch_array()?


php has lots of functions to fetch the data from mysql database. Here I am just trying to make out the difference between mysql_fetch_assoc() and mysql_fetch_array() functions of php.

mysql_fetch_assoc() is equivalent to calling mysql_fetch_array() with MYSQL_ASSOC for the optional second parameter.

mysql_fetch_assoc() is also doesn't really need to exist because it just returns the key names insted of Numeric keys and key names which happens in mysql_fetch_array.

'Associative arrays' returned by mysql_fetch_assoc() are arrays with key names so , they're more human readable.

Some times mysql_fetch_assoc() is faster than mysql_fetch_array() .

mysql_fetch_assoc() may also need less memory as it generates an array of key names insted of keynames and key indexes in mysql_fetch_array().

javascript setTimeout() recursion code

recursion with javascript setTimeout()



Purose of setTimeout function

We always use setTimeout() function of Javascript to execute some statement after some time interval. It dosent mean browser stops the execution at setTimeout statement. Infact browser just run the complete set script including the setTimeout function, and just keep in reminder that the statement written in setTimeout's first parameter has to be executed after some time duration.

Syntax
setTimeout("",1000);
first parameter : Statement to be executed.
second parameter : Time interval in ms.

How to write recursive script with this function?
Directly see the sample code below.

function call_me_recursively()
{
/*
some code here
*/
setTimeout(function() { call_me_recursively() },1000 );
}

It works.
Best of luck..

Shell Script - how to write

How to write shell script


A shell is a command line interpretor. It takes commands and executes them. We can run N no of common commands one after another by putting them in one file( shell script ) in proper order.

Creating a simple shell file

suppose you want to view the some files in some directory regularly. so you need to use following command:
find /path/to/folder/*.ext -mtime 30 -type f -exec ls -lh {} \;

This will display all files which are 30 days older from given folder path .

we can do this task in shell script as follows

#!/bin/sh
find /path/to/folder/*.ext -mtime 30 -type f -exec ls -lh {} \;
exit 0

_______________________________________________________________

How to create shell script file with vi editor.

1. vi file_name.sh - create the shell file

2. First statement of shell file should be
#!/bin/sh - start of shell script

3. write all commands one after another. - all commands to be executed

4.End of shell script - end of shell script
exit 0

5.come out of vi editor and run the shell file - run the shell file
./file_name.sh

simple.................
_______________________________________________________________

Passing value to shell script
We can also pass the arguments to our shell script. In our example we are displaying all the files which are modified 30 days before. Now suppose we want to see all the files which are modified 10 days before , then we need to make change in our shell script. To avoid this we can pass the date count to our script from command line. Just go through the sample file given below.

e.g.
#!/bin/sh
clear
echo *SCRIPT NAME = $0
echo *No Of Parameters = $#
echo *Parameters List = $*
echo List of files modified before $1 days.
find /path/to/folder/*.ext -mtime $1 -type f -exec ls -lh {} \;
exit 0

* echo is used to write output.
* $0 gives the script name.
* $# gives no of parameter count.
* $* gives a string of all parameters to script
* Individual argument can be accessed with $1,$2,$3,$4,$5.............
$1 for first parameter and so on..

How to execute
./file_name.sh +10
In this case +10 is passed to our shell script as first parameter and thus script runs accordingly.

Create Your Orkut Application

Steps to create orkut applications.

Platform

Orkut applications can be created in XML.

1. Start with the sandbox account on http://sandbox.orkut.com .
Register on http://code.google.com/support/opensocialsignup/
2. Once your account get active , you can start developing your application in sandbox.
3. You can add your XML application by clicking on add application tab.

HELP
http://code.google.com/apis/orkut/docs/orkutdevguide.html

First Time developing application?

http://code.google.com/apis/orkut/articles/tutorial/tutorial.html

CSS Properties To JavaScript

CSS Property vs JavaScript Reference


Check out the following list for all javascript Reference for all CSS styles.

background -> background
background-attachment -> backgroundAttachment
background-color -> backgroundColor
background-image -> backgroundImage
background-position -> backgroundPosition
background-repeat -> backgroundRepeat
border -> border
border-bottom -> borderBottom
border-bottom-color -> borderBottomColor
border-bottom-style -> borderBottomStyle
border-bottom-width -> borderBottomWidth
border-color -> borderColor
border-left -> borderLeft
border-left-color -> borderLeftColor
border-left-style -> borderLeftStyle
border-left-width -> borderLeftWidth
border-right -> borderRight
border-right-color -> borderRightColor
border-right-style -> borderRightStyle
border-right-width -> borderRightWidth
border-style -> borderStyle
border-top -> borderTop
border-top-color -> borderTopColor
border-top-style -> borderTopStyle
border-top-width -> borderTopWidth
border-width -> borderWidth
clear -> clear
clip -> clip
color -> color
cursor -> cursor
display -> display
filter -> filter
font -> font
font-family -> fontFamily
font-size -> fontSize
font-variant -> fontVariant
font-weight -> fontWeight
height -> height
left -> left
letter-spacing -> letterSpacing
line-height -> lineHeight
list-style -> listStyle
list-style-image -> listStyleImage
list-style-position -> listStylePosition
list-style-type -> listStyleType
margin -> margin
margin-bottom -> marginBottom
margin-left -> marginLeft
margin-right -> marginRight
margin-top -> marginTop
overflow -> overflow
padding -> padding
padding-bottom -> paddingBottom
padding-left -> paddingLeft
padding-right -> paddingRight
padding-top -> paddingTop
page-break-after -> pageBreakAfter
page-break-before -> pageBreakBefore
position -> position
float -> styleFloat
text-align -> textAlign
text-decoration -> textDecoration
text-decoration: blink -> textDecorationBlink
text-decoration: line-through -> textDecorationLineThrough
text-decoration: none -> textDecorationNone
text-decoration: overline -> textDecorationOverline
text-decoration: underline -> textDecorationUnderline
text-indent -> textIndent
text-transform -> textTransform
top -> top
vertical-align -> verticalAlign
visibility -> visibility
width -> width
z-index -> zIndex

How to detect the firebug.

I use this to detect the firebug.

How to check the empty directory in shell script

How to check the empty directory in shell script?

This can be easily done with the help ls command.
we can simply check the empty directory using following script.

DIR="/path/to/directory/"

if [ "$(ls -A $DIR)" ]; then
echo "Take action $DIR is not Empty"
else
echo "$DIR is Empty"

You can also assign the output of specific command to a separate variable instead of checking it directly in if condition.
e.g.

myVar=`(grep 'stringToSearch' filename.ext)`;

Note: Do not use spaces before and after =.

What is JSON - Alternative to XML

What is JSON

Javascript Object Notation

JSON make easy to interchange between programming language to JavaScript.

JSON is class/library that we can use to convert a variable from PHP variable to JavaScript Variable.

its another way to use javascript on your site and not have to worry about people having it turned off since doesn't require javascrpt tags to actually run it.


it make programing in javascript quicker and more effective.


It is a Fat-Free Alternative to XML.

It is a new data interchange format.

JSON data can be included from websites outside the domain origin of the web application (avoiding the same-origin limitations of XMLHttpRequest) by using JSON-in-script.


JSON can be be used as an alternative to XML representation of data with the added benefits that JSON is easier to "parse" for JavaScript client code


Sample code snippet to generate JSON string for php array.

'the first', 'b'=>'is second');

$json = new JSON();

echo $json->convert($myArray);
?>


1.) You can download the JSON.php file from this link:
http://mike.teczno.com/JSON/JSON.phps

check out following code.

require_once("JSON.php");

$myArray = Array('a'=>'the first', 'b'=>'is second');

$json = new Services_JSON();

echo $json->encode($myArray);

Output :
{"a":"the first","b":"is second"}


How to turn xml into json:

http://www-128.ibm.com/developerworks/xml/library/x-xml2jsonphp/

memory management in php

Memory management - php


Why memory problems occurs in our script??

Some time you might have came accross the following memory problem while executing your php script.
Fatal error: Allowed memory size of 8388608 bytes exhausted.
- We will start with php.ini.
In php configuration file ( php.ini ) there is a directive for memory limit that php script can use during the execution.
memory_limit
* Default memory limit is set in php.ini file ( php configuration file.)
* memory_limit = 8M;

Every time we create any variable or array some amount of space is allocated to that variable, and when this memory allocation exceeds the memory_limit ( in php.ini ) , the script throws the fatal error of allowed memory size.

If we are using any include file in loop then also this error may occure. If we are including any php file in loop , script try to create more n more variables and at some stage this loop creates memory management problem.

Always use memory_get_usage function after certain block of codes in your script to find which block of code is occupying more memory, then apply respected steps.

Click here to view all possible solutions on php memory management problems.

cacheing technique : server page cache

Hi guys.
Do you know the technique to create server side cacheing with php?
It is very simple and easy to understand. Page level server cache can be implemented by using the concept of output buffer and other output buffer handling functions.Output buffer is responcible to hold the data after ob_start() statement. So we can cache the complete page by writing simply ob_start(); at the beginning of page ( where output starts) and can write the content of output buffer in separate file. This file will now be treated as page level cache file for the main page.
1. use ob_start();
Every HTML output generated by your php page will be stored in output buffer. Output buffer is a php function.
2. Write the contents of current output buffer to any HTML file.
3. Stop the output buffering and clear the buffer. Any HTML output generated by your page after this statement will not be stored in output buffer.
OB_flush();
4. For next request of same page will be drawn from this cached HTML file and not by your actual php file.
Where to use page cache in php?
This type of server cacheing technique of php can only be used to avoid database hits in subsequent requests. But this is also applicable if and only if your data is not going to change for cached time.
Sample code for server side data cacheing is here.
MyCachefile = 'MyCache/cached.html';
$cachetime = 5 * 60;
// Serve from the cache if it is younger than $cachetime
if (file_exists(
$MyCachefile) && time() - $cachetime <>$MyCachefile)) {
include(
$MyCachefile);
echo "\n";
exit;
}
ob_start(); // Start the output buffer

/* The code to dynamically generate the page goes here */

// Cache the output to a file
$fp = fopen(
$MyCachefile, 'w');
fwrite($fp, ob_get_contents());
fclose($fp);
ob_end_flush();
?>

install php install

How to install php apache mysql


This post if for all php beginners who dont know how to install php, and searching for php installation steps.

Prerequisites
In order to install and learn php on your local computer system you need php
installation and an server software as well i.e.(Apache/IIS).


First we have to install apache server and then php and mysql.
so go through following steps to install apache server on your local system.
-------------------------------------------------------------------------------------
Download the latest Win32 Binary (MSI Installer) of apache web server.
click here for apache installation

You should download following version.

Version: 2.0.55
File Name: apache_2.0.55-win32-x86-no_ssl.msi

1. Download the apache installation file i.e. apache_2.0.55-win32-x86-no_ssl.msi.
2. Double click it and start the apache installation.
3. It is a normal installation so no need of brief explanation.
4. The installation wizard will ask you some fields "Network domain", "server name", "administrators email id" etc - you can enter anything in this fields.
5. Then choose typical installation and click on next button.
6. Finish the installation.
7. Open http://localhost/ and you will see the apache test page.
8. Apache installation is done.

Apache server's configuration settings is stored in a file called httpd.conf.
This file is located at C:\Program Files\Apache Group\Apache2\conf\ directory. You have to edit this file while installing php.
_____________________________________________________________

Install PHP
On the PHP download page, click on the zip package under the Windows Binaries section to download php. CLICLK HERE FOR PHP

You should download following version.
Version: 5.1.2
File Name: php-5.1.2-Win32.zip.

-------------------------------------------------------------------------------------
Now go through following simple steps to install php.

1. Extract php-5.1.2-Win32.zip to C:\php.
2. There is one file in php directory ( php-ini-recommended.ini ).
This is a configuration file of php.
Create a copy of this php configuration file and rename it to c:\php\php.ini.
3. Now open php.ini file in any text editor which you like and do the following changes and then save it.

a)Uncomment the "include_path" on. line 505.
include_path = ".;C:\php\includes"

b)Change the "doc_root" to match your httpd.conf DocumentRoot directory. line 512.
doc_root = "C:\Program Files\Apache Group\Apache2\htdocs"

c)Change "extension_dir". Line 519.
extension_dir = "C:\php\ext"

d)Change "session.save_path" and "session.cookie_path" on
line no 939 & 958, respectively
session.save_path = "C:\Temp"
session.cookie_path = \

4. Add C:\php to your PATH System Environment Variable
a.Right-click on My Computer and choose Properties.
b.Select the Advanced tab.
c.Click Environment Variables.
d.Under System variables, select “Path” and choose Edit.
e.Move the cursor to the end of the string and add
;C:\php. A basic path will look something like the following:
%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;C:\php
5. Click ok and finish it.

6.Open your httpd.conf file located at C:\Program Files\Apache Group\Apache2\conf\ and Append the following lines.

LoadModule php5_module "c:/php/php5apache2.dll"

AddType application/x-httpd-php .php

PHPIniDir "C:/php"


7.Add index.php to the DirectoryIndex, and then save. Line 321.
DirectoryIndex index.php index.html index.html.var

8. Restart the apache server and check that test apache page is displaying or not.

hacker proof PHP MySQL development

Hacker proof PHP MySQL

Who hack your website?
Answer : You.
( Hackers use many hacking techniques to hack your website or web server. But up to certain extent it is because of programmer. Confuse?? )
Programmer has to take precautions to prevent there script from hack attack. If you didn't think and code improperly then you increase the chance of your script being hacked.

Hack prevention Techniques / Tips
Study following hack prevention techniques to develop a secure and hack safe php mysql web application.

1. Protect all secure directories.
.htaccess file is our friend. Use .htaccess file to protect your secure directories.
Click here for more help on how to protect the directory using .htaccess

2. Set your server configuration properly
Set the register_globals setting to OFF. This you can do by editing your php.ini file. php.ini is the php configuration file which controls the behavior of your script. Register_globals is a PHP setting that controls the availability of variables by super global arrays of php ( i. e. $_SESSION, $_POST,$_REQUEST,$_GET,$_COOKIE n all super global arrays).
register_globals = "on" => less secure .
register_globals = "off" => more secure .
this setting is removed from php version 6.

3. Never trust the user data.
Never trust the data entered by user from the web forms. Validate all the user inputs either from POST form data or from GET query strings.
Always escape the user data.
study these setting and functions of php to achive this.
1. magic_quotes
2. addslashes()
3. stripcslashes()
4. strip_tags()
5. mysql_escape_string()


4. Move Config and files containing Passwords to mysql to a Secure directory outside of the public_html folder.

5. Turn off Display Error/Warning Messages.
set error_display to ZERO

Fatal error: Allowed memory size of 8388608 bytes exhausted php

sometime PHP script may returns the above error. Normally this error is generated when your script exchausted and used up the default memory requirement of 8 MB memory allocation.

* Default memory limit is set in php.ini file ( php configuration file.)

* memory_limit = 8M;

How can we manage with the memory problems comes in some php scripts?
you should check following things when such kind of memory errors occurs in your script.

1. check the default memory_limit variable in your php.ini file.
memory_limit = 8M;
you can change this memory limit and again check for the error.

a. Edit in php.ini
memory_limit = 12M;
restart the apache service.
b. code Level
@ini_set('memory_limit', '12M');
c. htaccess
php_value memory_limit 12M
___________________________________________________________________

2. If the error is not resolved after above step, then you should start debugging your code in order to find out the reason of memory limit exceed.
You have to first find out at what position in your code the memory limit is exceeding. you can use the php's built in function for this purpose.

Function description

memory_get_usage — This function returns the amount of memory allocated to PHP.

Syntax : int memory_get_usage ( true / false );

It returns the amount of memory, in bytes, that's currently being allocated to your PHP script.

Set the option to this function to TRUE to get the real size of memory allocated from system. If not set or FALSE only the memory used by emalloc() is returned.

How to use this function

1. Write this code ( echo memory_get_usage( true ); ) repeteadly after some no of lines.
2. Run it in browser
3. Compare the counts given by each echo and you can check which block of your code needs extra memory.
4. Once you identify the block of code which needs extra memory then you can start deallocating the unused memory spaces allocated by some unused variables and some infinite loops.
5. use following wherever necessary.
a. unset($var_name);
b. mysql_free_result($result_set); — Free result memory
c. Look for include("file.php") in loops, by mistake.
Just try to free the memory everywhere if the variable / array is no longer used.
6. Best of luck.


Function description

bool mysql_free_result ( resource $result )
It frees all the memory associated with the result identifier result .

Cross Site Scripting XSS browser attacks

Cross Site Scripting XSS


Now a days Web applications are becoming more and more dynamic. Dynamic websites means contents shown on web page are pulled dynamically depending on some settings. These setting may include sending some important variables in query string, or sending the data entered by users with post form type. So in simple words we can say that your dynamic web application needs some contents / data inputs from user, and this is the point where Cross Site Scripting
(XSS) comes in picture.
As your dynamic web application is accepting some data from users or from query string. Some users get the front door open to enter in your application and put there codes in your application. These Codes may include HTML code and/or JavaScript , any client-side scripts. Cross-site scripting technique is carried out on websites were roughly 80% of all documented security vulnerabilities.

What is XSS?

Usually attacker encodes some part of the links in HEX, and puts this in your web page through query string. So that script can be anything and we cant predict the behavior of such attacks to the web application.

Attack example : A simple JavaScript to read cookie is added to your page and then this cookie is sent to attackers action page which records all the information in the cookie created by yuor web application.

Refer folowing url


< src="" text="< script">alert(document.cookie)< / script>"> < / iframe>

If we are using the variable $text somewhere in our page and it is not escaped then this URL will render a new iframe on the place where you are using the $text variable.
In this way you can insert any of your script in another webpages and fool the users to get important information from them. But normally in such kind of attckes user never understand that there important information is being hacked by some other application.
This is the simple thing and will not cause much damage to your sitee, but attacker can do much more than this with the help of XSS.

Other XSS attacks
Attackers may inject JavaScript, VBScript, ActiveX, HTML in webpages.
This kind of attacks are done for hacking user accounts , changing of user settings, cookie theft, or advertising.

How to prevent such attacks ?

Clensing the Query String variables is the only way you can prevent such attackers.

Clensing the Query String - PHP :
string strip_tags ( string $str [, string $allowable_tags ] )
This function tries to return a string with all HTML and PHP tags stripped from a given str.

string htmlentities ( string $string [, int $quote_style [, string $charset [, bool $double_encode ]]] )

use above functions or you can write your own function which combines all such stripping functionlities.

PHP filter_input validate and filter User Inputs

PHP5 comes up with all new functionalities and lots of new extensions. While developing any web application we have to think about the security of that web application.
PHP5 has introduced its all new Filter Functions , which consists of really good and powerful filter functions helping developers to filter the external user inputs to there web application. Now a days web applications are becoming more dynamic than static. As web application become more dynamic , It accept more inputs from users, and this is the main security concern.. Thanks to php5 for introducing new set of filter functions which really help to make your application more secure.

PHP filters are used to validate and filter data coming from insecure sources.
e.g. User Inputs...

PHP filter_input() Function

With filter_input() function we can filter out the data from following sources.

1. INPUT_GET
2. INPUT_POST
3. INPUT_COOKIE
4. INPUT_ENV
5. INPUT_SERVER
6. INPUT_SESSION (Not yet implemented)
7. INPUT_REQUEST (Not yet implemented)

this function returns the filtered variable data on success and returns FALSE on the failure or of filter action.

Syntax
filter_input(input_type, variable, filter, options)

input_type = Above List of sources. e.g . INPUT_GET , INPUT_POST.
variable = Variable to be validated.
filter = Specifies the ID of the filter to use. Default is FILTER_SANITIZE_STRING.

Here is the list of php filters.
ID Name Description
FILTER_CALLBACK------------------Call a user-defined function to filter data
FILTER_SANITIZE_STRING-------Strip tags, optionally strip or encode special characters
FILTER_SANITIZE_STRIPPED--- Alias of "string" filter
FILTER_SANITIZE_ENCODED--- URL-encode string, optionally strip or encode special
characters
FILTER_SANITIZE_SPECIAL_CHARS
HTML-escape '"<>& and characters with ASCII value less than
32
FILTER_SANITIZE_EMAIL----------Remove all characters, except letters, digits and
!#$%&'*+-/=?^_`{|}~@.[]
FILTER_SANITIZE_URL------------Remove all characters, except letters, digits and $-_.+!*'(),
{}|\\^~[]`<>#%";/?:@&=
FILTER_SANITIZE_NUMBER_INT----Remove all characters, except digits and +-
FILTER_SANITIZE_NUMBER_FLOAT----Remove all characters, except digits, +- and optionally
.,eE
FILTER_SANITIZE_MAGIC_QUOTES----- Apply addslashes()
FILTER_UNSAFE_RAW----------------------- Do nothing, optionally strip or encode special
-------------------------------------------------------- characters
FILTER_VALIDATE_INT----------------------- Validate value as integer, optionally from the specified
-------------------------------------------------------- range
FILTER_VALIDATE_BOOLEAN-------------- Return TRUE for "1", "true", "on" and "yes", FALSE for
-------------------------------------------------------- "0", "false", "off", "no", and "", NULL otherwise
FILTER_VALIDATE_FLOAT------------------- Validate value as float
FILTER_VALIDATE_REGEXP---------------- Validate value against regexp, a Perl-compatible
------------------------------------------------------- regular expression
FILTER_VALIDATE_URL--------------------- Validate value as URL, optionally with required
------------------------------------------------------ components
FILTER_VALIDATE_EMAIL------------------ Validate value as e-mail
FILTER_VALIDATE_IP------------------------ Validate value as IP address, optionally only IPv4 or
------------------------------------------------------ IPv6 or not from private or reserved ranges

 
 
 

typo3 cms templates tutorial

PHP news

php freelancer mumbai India