I have a class as below, assuming this is an object:
class house {
private $windows;
function __construct() {
}
function setWindows() {
}
function getWindows() {
}
function countWindows() {
// this is object's method
}
}
if I add a function like this:
class house {
private $windows;
function __construct() {
}
function setWindows() {
}
function getWindows() {
}
function countWindows() {
// this is object's method
// call isGlassWindows() function here
}
function isGlassWindows () {
// this is not object's method
}
}
I know an object have properties and methods, right. So I’m only want to know I can add any function (not object’s method) for it or not. I see many project they code like #2.
I give an example to everyone to know objects have only properties and methods or not. If I write code with procedure (don’t use class), not object. I don’t need care properties, methods. Do you know what’s object?
Any instance of “house” will have the method isGlassWindows, I’m not sure why you think the method will not belong to the object. The ONLY way a method will not belong to the object directly is static methods, which are part of the class, not the object.
If you showed us an actual working example of what you are asking, I could give you more answers but in the example you’ve provided, isGlassWindows will belong to the object.