Sunday, November 9, 2014

Get Acknowledgement of Most Awesome and Useful PHP Functions

There are lots of built-in functions in PHP, but some of them are few well known as they are most useful for all PHP Programmers. Here, You will find cool PHP functions.

Most Useful PHP Functions

PHP Functions

1.. highlight_string() :-

highlight_string() function is really helpful while displaying PHP code. It provides a syntax highlighted version for the given PHP code with the use of colors defined in the built-in syntax highlighter for PHP. 

Usage :-
 <?php
highlight_string('<?php phpinfo(); ?>');
?>

Click Here to check documentation

2.. str_word_count() :-

The str_word_count() function takes a string as a parameter and return the count of words, as  per below example. 

Usage :-

?php
$str = "How many words do I have?";
echo str_word_count($str); //Outputs 5
?> 

Click Here to check documentation

3.. checkdate() :-

checkedate is a very useful to test a valid date submitted by an user. Checks the validity of the date formed by trhe arguments. You need to defined parameter properly to considered a valid date. 
Usage :-

<?php
var_dump(checkdate(12, 31, 2000));
var_dump(checkdate(2, 29, 2001));

//Output
//bool(true)
//bool(false)
?>

Click Here to check documentation

4.. get_defined_vars() :-

get_defined_vars is a very handy function while debugging. It offers a multidimensional array with a list of all defined variables, user-defined variables, server variables, within the scope that get_defined_vars() is called. 

Usage :-

print_r(get_defined_vars());

Click Here to check documentation

0 comments:

Post a Comment