Welcome Guest, Not a member yet? Register   Sign In
How to load Configuration Files as Array?
#1

(This post was last modified: 09-18-2019, 09:16 AM by bustersg.)

I am passing some environment settings to a view template but how do I pass it as an Array to avoid below error?

TypeError
Argument 2 passed to view() must be of the type array, object given

PHP Code:
<?php namespace Config;

use 
CodeIgniter\Config\BaseConfig;

class 
TestConfig extends BaseConfig
{
    /*
    |--------------------------------------------------------------------------
    | CAPTCHA
    |--------------------------------------------------------------------------
    |
     */
    public $captcha 1


PHP Code:
// Access config class with namespace
$config config'Config\\TestConfig' );

echo view('login', $config); 
Reply
#2

Try

PHP Code:
// Access config class with namespace
$config config'Config\\TestConfig' );
$data['captcha'] = $config->captcha;
echo 
view('login'$data); 
Reply




Theme © iAndrew 2016 - Forum software by © MyBB