Page 1 of 1

Names & Conventions question

Posted: Wed Jun 16, 2010 3:18 pm
by MiniMonty
Hi all,

I'm essentially a front end Flash developer and I'm learning php.
I'm having a little trouble understanding the naming of things.
In ActionScript (the native Flash OOP language) we have classes, functions, variables and routines
(plus a few other odd bits and pieces like event listeners)

I guess a variable is a variable is a variable in any language but reading through some php tutorials tonight I'm confused
by the use of "class", "method" and "function" which are clearly similar - but not quite the same as I'm used to.
I've done a fair bit of pretty basic php and I'd like to go more advanced so I need to sort this out in my head :?

Can anyone put me right with a few idiot proof definitions (and maybe comparisons with ActionScript) ?

Best wishes
Monty

Re: Names & Conventions question

Posted: Wed Jun 16, 2010 3:27 pm
by AbraCadaver
A variable is a variable but if it is defined as part of a class structure and available via the class then many times they are called properties or class properties. Functions are functions but class functions are many times referred to as methods or class methods.

Re: Names & Conventions question

Posted: Wed Jun 16, 2010 4:12 pm
by MiniMonty
AbraCadaver wrote:A variable is a variable but if it is defined as part of a class structure and available via the class then many times they are called properties or class properties.
Are those variables still available globally - or only as part of (or with reference to) the class ?
Functions are functions but class functions are many times referred to as methods or class methods.
Aha - I get the "method" name now. Same question - are those functions available globally or only within or with reference to the class ?

Might seem like obvious questions but I'm discovering that php and Actionscript, although both oop languages have very different
properties - php seems little more "forgiving" in some areas although Actionscript will allow an "empty" variable at any stage but
is less intuitive.

Best wishes
Monty

Re: Names & Conventions question

Posted: Wed Jun 16, 2010 4:32 pm
by AbraCadaver
The properties and methods are only available via the class or an object based on the class and they may have different visibility, public, private, protected.

Just like in JavaScript, if you have myObject.myVar and myObject.myMethod(), you can't just call myMethod() or use myVar.

Here is a good overview: http://php.net/manual/en/language.oop5.php