对于我的新工作,我必须学习PHP,到目前为止,我发现它非常令人沮丧(我习惯使用桌面语言,如C#,Java等)。
我在教自己这种语言,而且一次只创建一些项目。
现在我有三个班级:
Customer
DateOfBirth
Address
在Customer类中,我有getter和setter方法。对于setter方法,我想检查一个参数的类型。
例如:(伪):
func set_address($address)
if $address typeof Addess then
this->address = $address
else then
throw ArgumentException("Invalid parameter!");
end
end
我希望你明白我的意思。 我只是想让事情做对,而不是习惯做蠢事。
希望你能帮忙! 提前干杯!