Posts

Showing posts from August, 2011

PHP 5.3.8 Released!

All PHP users should note that the PHP 5.2 series is NOT supported anymore. All users are strongly encouraged to upgrade to PHP 5.3.8.

PHP Programming Tips

Functions And Methods Function And Method Calling call_user_func() is 54% slower than just calling the function call_user_func() is 59% slower than calling a static method call_user_func() is 65% slower than calling an object method function() is 119% faster than static::method() $this->method() is 116% faster than static::method() declared static::method() is 93% faster than static::method() Functions General Pass by reference is 3% faster than Return by reference No reference is 1.7% faster than Return by reference

PHP Programming Tips

Variable Operations Operating on an initialized variable is 376% faster than operating on an unitialized variable. Constants are 146% slower than variables Local variables are 9.9% faster than global variables String Functions 'String' is 0.26% faster than "String" "String" is 4% faster than HEREDOC syntax "String\n" is 108% faster than 'String'."\n" 'String'.$var is 28% faster than "String$var" 'string '.$var.' string' is 55% faster than sprintf('string %s string', $var) "\n" is 70% faster than chr(10) strnatcmp() is 4.95% faster than strcmp() strcasecmp() is 45% faster than preg_match() strcasecmp() is 6.6% faster than strtoupper($string) == "STRING" strcasecmp() is 13% faster than strnatcasecmp() strtr($string, $string1, $string2) is 10% faster than str_replace() str_replace() is 161% faster than strtr($string, $array) stristr() is 10%

How to get the number of parameter with their name of a defined function

You can get the number of parameters with their name of a function. PHP provides a class ReflectionFunction. It's a built-in class, so no need to add any extra library. <?php function get_func_argNames($funcName) { $f = new ReflectionFunction($funcName); $result = array(); foreach ($f->getParameters() as $param) { $result[] = $param->name; } return $result; } print_r(get_func_argNames('get_func_argNames')); ?>

Check If The User Likes (Fan Of) Your Facebook Page When Landing On Your Page Tab

Check when user landed on facebook fan page tab, Wheather he is fan of this page or not ? A lot of developers and admins Facebook pages don’t know that they can detect whether the visiting user is already a fan of the page or not. When the user visit your Page Tab, Facebook will send you the usual signed_request but with additional parameter called  page .

Track Facebook Like Button Event

Why Track Facebook Like Button Event Lets take an example of any online Store. We want to show some coupon code, when user Like my Product. In That case we need to '''Track Facebook Like Button Event'''. '''We can track the Facebook like Activity  ''' To Track the Activity following Points are Important: We can Track Facebook Like button Click only by XFBML Method. '''FB.Event.subscribe''' Method is used to Track the Like and Unlike.