Extract variables from php file from function in another file
P粉198670603
P粉198670603 2023-09-07 13:33:37
0
1
550

I have a php file in the root directory and I want to retrieve a variable from a function in another php file. I need it for SQL queries.

My php file is in the root directory

<?php
    require dirname(__FILE__) . '/config/config.inc.php';
    require 'modules/pricefrom/pricefrom.php';

    $lowestPrice = Db::getInstance()->getValue('
            SELECT MIN(`price`)
            FROM `' . _DB_PREFIX_ . 'product_attribute`
            WHERE `id_product` = ' . (int)$id_product
    );

I need to get $id_product from another file that is required and is inside a function and uses the parameters of that function.

<?php
    ...
    public function hookDisplayPriceBlock($param) {
            $id_product = $param['id_product'];
            $id_product_attribute = $param['id_product_attribute'];
            $product = new Product();
            ...

I know there is an easy way to do this, but I've been searching for hours and can't find it, can you guys help me?

P粉198670603
P粉198670603

reply all(1)
P粉256487077

Use

in the root directory
require_once('<path to file2.php>');
$id_product = hookDisplayPriceBlock(<params>);
.....

File 2

public function hookDisplayPriceBlock($param) {
    ...
    return $id_product;
}
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template