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 8900993
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T01:14:20+00:00 2026-06-15T01:14:20+00:00

Im trying to figure out how namespaces works in PHP, but havent really been

  • 0

Im trying to figure out how namespaces works in PHP, but havent really been lucky

Hope somebody could tell me what Im doing wrong here 🙂

code

require_once 'Vatcode.php';
$Vatcode = new \resource\Vatcode();

Vatcode.php

namespace resource;

require_once Ini::get('path/class').'/Resource.php';

class Vatcode extends Resource {
    public function __construct(){
        echo 'works!';
    }
}

Rescource.php

namespace resource;

class Resource {

}

error

Fatal error:  Class 'resource\Ini' not found in Vatcode.php
  • 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-15T01:14:22+00:00Added an answer on June 15, 2026 at 1:14 am

    it’s just a problem of namespace.
    Your class Vatcode is in namesapce ressource. If, in the file of VatCode declaration you use nameofclas::... or new nameofclass() it will try to get the class in namespace ressource.
    If you want to use the class Ini inside your document you have two solutions :

    first give the full qualified name :

    require \namespace\of\ini\Ini::get('path/class').'/Resource.php';
    

    second using the “use” keyworld before using the get method :

    use \namespace\of\ini\Ini;
    require_once Ini::get('path/class').'/Resource.php';
    

    In any case, if Ini is in “no namespace” (global namespace is the accurate word) you just has to use the solutions I gave you but only with \Ini instead of \namespace\of\ini\Ini

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

Sidebar

Related Questions

I'm new to WPF and I'm trying to figure out how data binding works,
I've been trying to figure out how to use an XML Schema to validate
I've been struggling for a while now trying to figure this out and I'm
I have been spinning my wheels now for awhile trying to figure out how
For the past few days, I have been trying to figure out how to
I'm trying to figure out how classes work, but I'm having a bit of
This might be a weird question but I'm trying to figure out why the
After doing some research about namespacing in PHP I'm trying to figure out what
I've got a work around for this issue, but I'm trying to figure out
I've been online for days trying to figure this one out and, while I've

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.