What would you like to do?

What is the difference between function and method?

already exists.

Would you like to merge this question into it?

already exists as an alternate of this question.

Would you like to make it the primary and merge this question into it?

exists and is an alternate of .

functions have independent existence means they are defined outside of the class e.g. in c main() is a function while methods do not have independent existence they are always defined inside class e.g. main() in Java is called method.

########
I've been studying OOP lately and had this question myself, so I will share my thoughts;

I was taught that "A Function should do 1(one) thing and do it well."

In specific Regards to PHP;
The difference between a Method and a Function is that a Method is tied to a specific class.

Hope this helps.



--------------------------------------------------------------------------------------------------------
function can return value where as method can't that is the main difference between function and method

---------------------------------------------------------------------------------------------------

Actually you are describing the difference between a function and a procedure. Function returns a value, procedure does not unless you are using c#, then everything is a function.

In c# a function, to paraphrase the first answer, does and thing and does it well. A method contains functions. The most important method is the Main method. All functionality of a program must be referenced in the Main method because when you run a program, it starts at the beginning of the Main method, and stops wehn it hits end of the Main method.
19 people found this useful
Thanks for the feedback!

What is the difference between methodism and evangelism?

All Methodists are Evangelists, but not all Evangelists are Methodists. Methodism was born our of Evangelism when some Evangelical preachers were so vigorous in their preachin

What is the difference between the GET and POST methods?

As per functionality both GET and POST methods were same.Difference is GET method will be showing the information information to the users.But in the case of POST method infor

What is the difference between method and strategy?

A method typically involves a set of actions that can be followed in a given situation. A strategy involves a plan for how to solve a problem. While methods tend to be fairly

What is the difference between strategy and method?

A method typically involves a set of actions that can be followed in a given situation. A strategy involves a plan for how to solve a problem. While methods tend to be fairly

What is the difference between Constructor and Function or Method?

Constructor will be automatically invoked when an object is created whereas method has to be called explicitly.   Constructor needs to have the same name as that of the cla

What is difference between approach and method?

An approach = dealing with something    Method = a particular way of doing something:

What is the difference between a method and a procedure?

A procedure is a set of prescribed actions or events that must be enacted or take place to achieve a certain result. A method is a style or set of assumptions with which one a

What is the difference between method and technique?

In general Method is the general or specific way in which an activity is conducted, while techniques are the various methods and processes developed through knowledge, skill,

What is the difference between a method and process?

A process is the way you do something throughout the act of doing it. A method is the special way you adopt in performing your task. For example, to design a website you n

What is the difference between a recipe and a method?

a recipe is a list of ingredients, with the cooking instructions for a specific dish. a method is the way a dish is cooked- fried, boiled, pan-seared,etc.

What is the difference between a function and a method?

    Answer       In an Object Oriented Programming (OOP) language like Java, it is called a method. In a procedural language (like QBASIC or PHP) it is c

What is the difference between materials and method?

A material is something you use, like a spoon or an arrow. But a method is a special way of doing something. For example: "Whenever Nora's cat wasn't in sight, she would shake