I'm not used to not initializing variables. I'm currently trying to build a OOP calendar script as practice. Is the following valid?
private $name;
public $name;
also can you forcefully define the variable type?
string private name
I'm having a lot of trouble with syntax so I appoligize. I've tried going through php.net and while it is nice it's not very detailed and it's hard to find answers sometimes.
The reason for this question is the following:
class Calendar
{
private $name;
private $owner;
private $public;
function __construct()
{
load_classes();
set_name('default');
set_owner('none');
set_public(true);
}
function __construct($name_temp, $owner_temp, $public_temp)
{
load_classes();
set_name($name_temp);
set_owner($owner_temp);
set_public($public_temp);
}
}
That is simply an example but it might help for you (the reader) to understand what I'm trying to do and why.
I'm aware that PHP doesn't define it's types, but say you make 2 constructors both take in a single variable, one being a string the other being an int, how would PHP solve this?