Names & Conventions question

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
MiniMonty
Forum Contributor
Posts: 196
Joined: Thu Sep 03, 2009 9:09 am
Location: UK

Names & Conventions question

Post 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
User avatar
AbraCadaver
DevNet Master
Posts: 2572
Joined: Mon Feb 24, 2003 10:12 am
Location: The Republic of Texas
Contact:

Re: Names & Conventions question

Post 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.
mysql_function(): WARNING: This extension is deprecated as of PHP 5.5.0, and will be removed in the future. Instead, the MySQLi or PDO_MySQLextension should be used. See also MySQL: choosing an API guide and related FAQ for more information.
MiniMonty
Forum Contributor
Posts: 196
Joined: Thu Sep 03, 2009 9:09 am
Location: UK

Re: Names & Conventions question

Post 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
User avatar
AbraCadaver
DevNet Master
Posts: 2572
Joined: Mon Feb 24, 2003 10:12 am
Location: The Republic of Texas
Contact:

Re: Names & Conventions question

Post 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
mysql_function(): WARNING: This extension is deprecated as of PHP 5.5.0, and will be removed in the future. Instead, the MySQLi or PDO_MySQLextension should be used. See also MySQL: choosing an API guide and related FAQ for more information.
Post Reply