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

  • SEARCH
  • Home
  • 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 7906493
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T10:59:48+00:00 2026-06-03T10:59:48+00:00

Today I wanted to write a simple php script, but I got some annoying

  • 0

Today I wanted to write a simple php script, but I got some annoying errors.
I just simply include the config.php file and try to access the root_path variable without success. There are also 2 other warnings that only show when I include the config.php file.

The files are running on the newest xampp.

smarty_setup.php :

<?php
require('config.php');
require($root_path . '/libs/Smarty.class.php');

class FileHosting extends Smarty {

   function __construct()
   {
        parent::__construct();

        $this->setTemplateDir($root_path . '/templates/');
        $this->setCompileDir($root_path . '/templates_c/');
        $this->setConfigDir($root_path . '/configs/');
        $this->setCacheDir($root_path . '/cache/');
        $this->caching = Smarty::CACHING_LIFETIME_CURRENT;
        $this->assign('app_name', 'File Hosting');
   }
}
?>

config.php :

<?php
    $root_path = 'D:/xampp/htdocs/example';
    $db_user = 'xxx';
    $db_password = 'xxx';
    $db_name = 'xxx';
    $db_host = 'xxx';
    $facebook_appID = 'xxx';
    $facebook_secret = 'xxx';
?>

Errors :

Deprecated: Assigning the return value of new by reference is deprecated in D:\xampp\php\PEAR\Config.php on line 80

Deprecated: Assigning the return value of new by reference is deprecated in D:\xampp\php\PEAR\Config.php on line 166

Notice: Undefined variable: root_path in D:\xampp\htdocs\example\includes\smarty_setup.php on line 3

Notice: Undefined variable: root_path in D:\xampp\htdocs\example\includes\smarty_setup.php on line 11

Notice: Undefined variable: root_path in D:\xampp\htdocs\example\includes\smarty_setup.php on line 12

Notice: Undefined variable: root_path in D:\xampp\htdocs\example\includes\smarty_setup.php on line 13

Notice: Undefined variable: root_path in D:\xampp\htdocs\example\includes\smarty_setup.php on line 14

Thanks for helping me.

  • 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-03T10:59:57+00:00Added an answer on June 3, 2026 at 10:59 am

    Inside your class, you are accessing $root_path, which is at the global scope. Pass it into the constructor:

    class FileHosting extends Smarty {
    
       // Pass $root_path as a param to the constructor
       function __construct($root_path)
       {
            parent::__construct();
    
            $this->setTemplateDir($root_path . '/templates/');
            $this->setCompileDir($root_path . '/templates_c/');
            $this->setConfigDir($root_path . '/configs/');
            $this->setCacheDir($root_path . '/cache/');
            $this->caching = Smarty::CACHING_LIFETIME_CURRENT;
            $this->assign('app_name', 'File Hosting');
       }
    }
    
    // Instantiate as
    $smarty = new FileHosting($root_path);
    

    The first of these errors is puzzling, as it would indicate that config.php was not properly included.

    Notice: Undefined variable: root_path in D:\xampp\htdocs\example\includes\smarty_setup.php on line 3
    

    If those are indeed the only contents of config.php (and you have not set those variables inside a function for example), you ought not get that first root_path notice.

    Update

    If you are failing to include config.php with a relative path, make sure:

    1. config.php is in the same directory as the file you are attempting to include it from
    2. Check your PHP include_path to be sure it includes the current directory .:

    .

    echo get_include_path();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Lexical analyzers are quite easy to write when you have regexes. Today I wanted
I just learnt XSLT today when I wanted to pretty print the playlist export
I just asked a question earlier today because I wanted to run an executable
today I just opened my 1,5 month old project and wanted to add a
Today I wanted to perform this task, and I run across some issues in
today I wanted to use some variables in my shared/menu partial. I know that
Today I wanted to re-do my vim installation, so I deleted some folders and
Today I wanted to unlock the WP7 emulator in order to see some more
I watched a video today and the guy in the video just write this
We just got a midterm project today for my operating systems course, we are

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.