• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Is it correct to say function?

#1
I am new to CI and PHP. I am studying
https://codeigniter.com/user_guide/libra...onfig.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?
Reply

#2
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";
    }

Reply

#3
(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!
Reply


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.