calling a function inside a class from another class php

Ketki Nimdeo

I am very new to oops in php. Can anyone tell me how can i use a function

    public static function getCategories($id_lang = false, $active = true,$order = true, $sql_filter = '', $sql_sort = '', $sql_limit = '')
            {
             if (!Validate::isBool($active))
             die(Tools::displayError());
             $result = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS('
              SELECT *
              FROM `' . _DB_PREFIX_ . 'category` c
              ' . Shop::addSqlAssociation('category', 'c') . '
              LEFT JOIN `' . _DB_PREFIX_ . 'category_lang` cl ON c.`id_category` = cl.`id_category`' . Shop::addSqlRestrictionOnLang('cl') . '
              WHERE 1 ' . $sql_filter . ' ' . ($id_lang ? 'AND `id_lang` = ' . (int)$id_lang : '') . '
              ' . ($active ? 'AND `active` = 1' : '') . '
             ' . (!$id_lang ? 'GROUP BY c.id_category' : '') . '
              ' . ($sql_sort != '' ? $sql_sort : 'ORDER BY c.`level_depth` ASC, category_shop.`position` ASC') . '
            ' . ($sql_limit != '' ? $sql_limit : '')
                      );

                if (!$order)
                   return $result;

                   $categories = array();
                   foreach ($result as $row)
                   $categories[$row['id_parent']][$row['id_category']]['infos'] = $row;

               return $categories;
              }

getCategories() is inside a class named class CategoryCore i want to use this getcategory into a new class totalDiscount in which a function called configure_products();

How can i use getcategory() inside the configure products?

Meenesh Jain

include the class file on the page

You can create a object of the class inside another class

function configure_products(){
    $categories = new CategoryCore();
    $categories->getcategory();
   // use $categories to do stuff 
     ......
     .....
}

OR

You can call it directly

function configure_products(){
     $categories =   CategoryCore::getCategories();
     .....
     ....
}

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

PHP Calling A Class function inside B Class

From Dev

Calling a function from another class?

From Dev

Calling function from one class in another class

From Dev

PHP - Calling database class from another class

From Dev

Calling a method from inside of another class

From Dev

Calling php function from inside another function

From Dev

Calling a class function from within another function

From Dev

Python calling a function from another function in a class

From Dev

C++ : Calling a constructor from a class inside another class

From Dev

Calling function from another class (React)

From Dev

Kotlin: Calling a function from another class

From Dev

Calling a function from another class? Android

From Dev

Calling Function from another class swift

From Dev

Calling function from another class in Kivy

From Dev

Calling member function of one class from another

From Dev

Calling a function from another class in Swift

From Dev

Python - Calling a function from another class

From Dev

Calling a function from one kotlin class in another

From Dev

Flutter: Calling Function from another Class State

From Dev

PHP: calling a parent class from another file

From Dev

PHP - Call class function from another class

From Dev

C++ calling a class function inside another function

From Dev

Calling class functions from another class function with JavaScript

From Dev

Calling a class from within another class PHP7

From Dev

Calling a recursive function inside a class

From Dev

Initiating and calling a function inside class

From Dev

Calling an async function inside a class

From Dev

Calling a method from inside a thread to another class in python pyqt

From Dev

Calling a method from another method inside the same class using getattr

Related Related

  1. 1

    PHP Calling A Class function inside B Class

  2. 2

    Calling a function from another class?

  3. 3

    Calling function from one class in another class

  4. 4

    PHP - Calling database class from another class

  5. 5

    Calling a method from inside of another class

  6. 6

    Calling php function from inside another function

  7. 7

    Calling a class function from within another function

  8. 8

    Python calling a function from another function in a class

  9. 9

    C++ : Calling a constructor from a class inside another class

  10. 10

    Calling function from another class (React)

  11. 11

    Kotlin: Calling a function from another class

  12. 12

    Calling a function from another class? Android

  13. 13

    Calling Function from another class swift

  14. 14

    Calling function from another class in Kivy

  15. 15

    Calling member function of one class from another

  16. 16

    Calling a function from another class in Swift

  17. 17

    Python - Calling a function from another class

  18. 18

    Calling a function from one kotlin class in another

  19. 19

    Flutter: Calling Function from another Class State

  20. 20

    PHP: calling a parent class from another file

  21. 21

    PHP - Call class function from another class

  22. 22

    C++ calling a class function inside another function

  23. 23

    Calling class functions from another class function with JavaScript

  24. 24

    Calling a class from within another class PHP7

  25. 25

    Calling a recursive function inside a class

  26. 26

    Initiating and calling a function inside class

  27. 27

    Calling an async function inside a class

  28. 28

    Calling a method from inside a thread to another class in python pyqt

  29. 29

    Calling a method from another method inside the same class using getattr

HotTag

Archive