PHP useful functions | Lessoncup Programming Blog

Tuesday, 15 October 2013

PHP useful functions

PHP is the most widely used web based programming language that powers millions of websites including some of the most popular one like Facebook. In Php we have some regular function where people use it regularly. what i thought as a web developer y can't i share my knowledge to my readers and help them on some projects because even after using PHP for years, we stumble upon functions and features that we did not know about. Some of these can be quite useful, yet underused. as a PHP develop you should familiar with functions and features.




Find the string length

The strlen() function returns the length of a string.
<?php

$one="php useful functions";

echo strlen($one);

?>


Reverse the String

The strrev() function reverse a string
<?php

$one="php useful functions";

echo strrev($one);

?>


Return a part of a String

The substr(string, start position, limit position) function return a part of a string. the function contain 3 parameters
<?php

$one="php useful functions";

echo substr($one,0,5);

?>


Wrap a String


The wordwrap(string, start position, limit position) function wraps a string to a given number of characters. using break character we can wrap the string.
<?php

$one="php useful functions for all php developers";

echo wordwrap($one,10,"<br/>/n");

?>


Calculate the md5 hash string


The md5(string) function is convert the string to a special hash string. this function is use various areas like password protection and other security data.
<?php

$one="php useful functions for all php developers";

echo md5($one);

?>

Coverting to clean URL


The urlencode(string) function is convert the url to clean url.
<?php

$new="This is lessoncup";

$enc=urlencode($new); 

echo $enc;

echo urldecode($enc);

?>

4 comments :

  1. echo strre($one);

    correct this line of code

    ReplyDelete
  2. why you don't write the output under every code example. this will make it more clear

    ReplyDelete

Mohammad Khasim
Blogger | Web Developer
Hyderabad - INDIA
lessoncup@gmail.com

PHP | My SQL | JQUERY
Web Development Tools | CMS | Frameworks | SEO

Get my Latest Lessons