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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T03:18:29+00:00 2026-06-16T03:18:29+00:00

I have a PHP project structured as: –root |–dr1 | |—dr2 | |–testclass.php |–start.php

  • 0

I have a PHP project structured as:

--root
 |--dr1
 |   |---dr2
 |        |--testclass.php
 |--start.php
 |--bootstrap.php

The testclass.php contains:

 namespace dr1\dr2;

 class testclass { 
     ... 
 }

The bootstrap.php contains:

define('DIR_SEP', DIRECTORY_SEPARATOR);
define('ROOT', dirname(__FILE__) . DIR_SEP);

function __autoload($class)
{
    $path = ROOT . str_replace('\\', DIR_SEP, $class);
    $file = $path . '.php';
    if( is_file($file) ) require_once($file);
}

spl_autoload_extensions('.php');
spl_autoload_register('__autoload');

and The start.php contains:

$class = 'dr1\dr2\testclass.php';
$obj   = new $class();

When I run the start.php, I got the message dr1\dr2\testclass.php is not found on start.php on line 5. I could not figure out why. would anybody help. thanks a lot.

  • 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-16T03:18:31+00:00Added an answer on June 16, 2026 at 3:18 am

    The autoloader looks correct, so the problem is the Classname testclass.php. In you source-file it’s just testclass without the .php – so if you adjust your $class-variable like that it should work:

    $class = 'dr1\dr2\testclass';
    $obj   = new $class();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

When I update my Symfony2 project I always have to do this: root@xxx:/var/www/project# php
Guys I have the following structure in my project. application/ Bootstrap.php configs/ application.ini modules/
I have a PHP project setup in Netbeans (v6.8) where all the PHP files
All, We have a PHP project in SVN. We develop code and do SVN
In my PHP project I have two different models that have a function with
I have a large-ish PHP project (hundreds of files) that I've been brought in
I have this problem getting my newly created php project on Netbeans work on
I have 2 applications. App1 is some old selfmade php project, not using Zend.
Ok, I'm working on a php college project, and I have to let students
We have a project (Web/PHP) where we would like users to access their files,

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.