This Is A Custom Widget

This Sliding Bar can be switched on or off in theme options, and can take any widget you throw at it or even fill it with your custom HTML Code. Its perfect for grabbing the attention of your viewers. Choose between 1, 2, 3 or 4 columns, set the background color, widget divider color, activate transparency, a top border or fully disable it on desktop and mobile.

This Is A Custom Widget

This Sliding Bar can be switched on or off in theme options, and can take any widget you throw at it or even fill it with your custom HTML Code. Its perfect for grabbing the attention of your viewers. Choose between 1, 2, 3 or 4 columns, set the background color, widget divider color, activate transparency, a top border or fully disable it on desktop and mobile.
27 03, 2010

call_user_func

By | 2010-03-27T09:07:44+00:00 March 27th, 2010|Categories: PHP, Ruby|Tags: , |Comments Off on call_user_func

The call_user_func() function in PHP calls a user defined function as specified by the first parameter. You can also use call_user_func() to call an instance method of an object by using an array(instance, methodName) parameter as follows:

PHP

class User{
  private $name = null;
 
  public function __construct($name){
     $this->name = $name;
  }

  public function getName(){
    return $this->name;
  }
}

$user = new User('Shaymol');
echo call_user_func( array($user, 'getName') );

// => Shaymol 

To get same behavior in Ruby we can call the send() method of an object as follows:

Ruby

# define a user class
class User
  attr_accessor :name

  def initialize(name)
     @name = name.capitalize
  end

end

# create a user object
user = User.new('Shaymol')

# this is similar to user.name, and in PHP similar to call_user_func($obj, 'methodName');
puts user.send(:name)

# => Shaymol

This page was contributed by Shaymol. Thanks!