CodeIgniter Forums
Is it correct to say function? - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Development (https://forum.codeigniter.com/forumdisplay.php?fid=6)
+--- Forum: Issues (https://forum.codeigniter.com/forumdisplay.php?fid=19)
+--- Thread: Is it correct to say function? (/showthread.php?tid=75559)



Is it correct to say function? - Md Asraful Haque - 02-21-2020

I am new to CI and PHP. I am studying
https://codeigniter.com/user_guide/libraries/config.html

There are two ways to load a config file:
Manual Loading
To load one of your custom config files you will use the following function within the controller that needs it:


We know when we call by object it is called a method, however the above line used the term function , Why?


RE: Is it correct to say function? - dave friend - 02-21-2020

A "method" is a "function" that belongs to a class. Though "method" would be a more precise description either term is correct.

Keep in mind that a class method is defined using the keyword "function", e.g.

PHP Code:
<?php
class SimpleClass
{
    
// method definition
    
public function displayHello() {
        echo 
"Hello World";
    }




RE: Is it correct to say function? - Md Asraful Haque - 02-26-2020

(02-21-2020, 07:43 PM)dave friend Wrote: A "method" is a "function" that belongs to a class. Though "method" would be a more precise description either term is correct.

Keep in mind that a class method is defined using the keyword "function", e.g.

PHP Code:
<?php
class SimpleClass
{
    // method definition
    public function displayHello() {
        echo "Hello World";
    }


Thank you so much!