class booking_diary {

// Time Related Variables
$a="09:30";
$b="19:00";

public $booking_start_time = $a; 
public $booking_end_time = $b;

}

I have an input fields where the user will set the $a,and $b fields instead of fixing the dates in the code.

Can i do this.
Please help. Thank you

Use the __construct() function. It is called when the object is instantiated (i.e. when you execute $object = new Object();.

Example:

class booking_diary {
    // Time Related Variables
    public $booking_start_time; 
    public $booking_end_time;

    public function __construct($a, $b) {
        $this->booking_start_time = $a;
        $this->booking_end_time = $b;
    }
}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.