Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8828695
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T07:39:59+00:00 2026-06-14T07:39:59+00:00

I am writing a config file parser and have a function called getVals() in

  • 0

I am writing a config file parser and have a function called getVals() in my Config.php file but apparently when I call it in a test it throws an “Undefined function” error.

Config.php

<?php

require_once '../extlib/pear/Config/Lite.php';

class Config {

private $config;

function __construct($conf) {
    $this->config = new Config_Lite();
    echo "calling open...<br>";
    $this->open($conf);
    echo "open done...<br>";
}

function open($cfile) {
    if (file_exists($cfile)) {
        $this->config->read($cfile);
    } else {
        file_put_contents($cfile, "");
        $this->open($cfile);
    }
}

function getVals() {
    return $this->config;
}

function setVals($group, $key, $value) {
    $this->config->set($group, $key, $value);
}

function save() {
    $this->config->save();
}

}

?>

Testing class in cfgtest.php

<?php

error_reporting(E_ALL);
ini_set("display_errors", 1);

require_once '../util/Config.php';

$cfile = "../../test.cfg";
$cfg = new Config($cfile);
if (is_null($cfg)) {
    echo "NULL";
} else {
    echo $cfg.getVals();
}


?>

Output

calling open...
open done...
Fatal error: Call to undefined function getVals() in cfgtest.php on line 13

I would like to know why the undefined function error appears when there’s the function there already.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T07:40:00+00:00Added an answer on June 14, 2026 at 7:40 am

    In php to call a method or a member of an object, use the -> operator:

    if (is_null($cfg)) 
    {
         echo "NULL"; 
    } 
    else 
    {
         echo $cfg->getVals(); 
    }
    

    Learn more on PHP Object Oriented Programming on PHP’s website.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In context - I'm writing a simple, standalone config file parser for a class
I'm writing code in PHP that requires including a config.php file depending on the
I have a config file that is a php array named config.php. return array(
Possible Duplicate: Reading and Writing Configuration Files Okay, I have a config file, which
I'm writing a bash script to modify a config file which contains a bunch
Writing a test app to emulate PIO lines, I have a very simple Python/Tk
I'm writing in C# and trying to represent an XML config file through an
NET MVC project i have following tag in in web.config file <authentication mode=Forms> <forms
I'm writing a simple ini file parser and I'm having a little problem with
I am writing an application that has a very loosely defined config file that

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.