No you can not, you have to pass the object as a parameter to your function.

greedyman
—
2012-12-16T16:19:38Z —
#3

ScallioXTX said:

No you can not, you have to pass the object as a parameter to your function.

But, if this is an object's method, should I use like this?

ScallioXTX
—
2012-12-16T17:36:34Z —
#4

greedyman said:

But, if this is an object's method, should I use like this?

I don't know what you want to do so I'm afraid can't answer that question. Could you explain a bit more?

greedyman
—
2012-12-17T13:56:51Z —
#5

ScallioXTX said:

I don't know what you want to do so I'm afraid can't answer that question. Could you explain a bit more?

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.

StarLion
—
2012-12-17T14:11:18Z —
#6

I'm confused by you saying it's not the object's method. It's a method defined within the object; therefore it is the object's method.

Scallio: Cant it be called by $this->isGlassWindows() ? (My OOP skills are sorely lacking.)

greedyman
—
2012-12-17T17:16:48Z —
#7

StarLion said:

I'm confused by you saying it's not the object's method. It's a method defined within the object; therefore it is the object's method.

Scallio: Cant it be called by $this->isGlassWindows() ? (My OOP skills are sorely lacking.)

isGlassWindows() is a function, assuming that it's not object's method.

Thank all!

KyleWolfe
—
2012-12-17T17:38:54Z —
#8

My question is what is setWindows going to be doing? This is probably where you will define wether they are glass correct?

KyleWolfe
—
2012-12-17T17:39:47Z —
#9

StarLion said:

Scallio: Cant it be called by $this->isGlassWindows() ? (My OOP skills are sorely lacking.)

Yes, it can

greedyman
—
2012-12-19T12:33:21Z —
#10

K_Wolfe said:

My question is what is setWindows going to be doing? This is probably where you will define wether they are glass correct?

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?

Cups
—
2012-12-21T14:26:35Z —
#11

hmmm .....

Not sure I have completely understood this, but going back to the OP.

greedyman said:

Can I call "house class" is an object?

Is my object really an instance of a house? Use the function is_a()

$b = new house;
if( is_a($b, "house") ) {
echo 'yep, $b is an object of the house class';
}

system
—
2012-12-21T14:35:07Z —
#12

Cups said:

hmmm .....

Not sure I have completely understood this, but going back to the OP.

Is my object really an instance of a house? Use the function is_a()

`php

$b = new house;

if( is_a($b, "house") ) {echo 'yep, $b is an object of the house class';

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.