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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T07:26:08+00:00 2026-06-12T07:26:08+00:00

Possible Duplicate: Derived class defined later in the same file “does not exist”? Does

  • 0

Possible Duplicate:
Derived class defined later in the same file “does not exist”?

Does anyone has the slighties idea why I’m getting a Fatal Error: Class ‘PublicacionController’ not found when trying to initialize it in the if statement below ?

--PublicacionController.php--
<?php
/*Some random includes, those are 
right as far as Im concerned*/

//AJAX call
if(!empty($_POST)){
    if($_POST['call']=='nuevaPublicacion'){
        $pc = new PublicacionController();
        $pc->nuevaPublicacion($_POST);
        exit;
    }
}

class PublicacionController extends Controller{/* STUFF*/}
?>

It is a single file. Im calling the controller from an AJAX call (dunno if it has something to do with).

I’m running a standard Amazon Ec2 instance, with Amazon Linux and the default https and PHP versions from the repos (the same Fedora uses I think).

  • 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-12T07:26:09+00:00Added an answer on June 12, 2026 at 7:26 am

    PHP classes should be defined before instantiation, see the “new” section of the PHP OO documentation.

    An easy way to achieve that is by first declaring the classes and then the main code:

    --PublicacionController.php--
    <?php
    /*Some random includes, those are 
    right as far as I'm concerned*/
    
    class PublicacionController extends Controller{/* STUFF*/}
    
    //AJAX call
    if(!empty($_POST)){
        if($_POST['call']=='nuevaPublicacion'){
            $pc = new PublicacionController();
            $pc->nuevaPublicacion($_POST);
            exit;
        }
    }
    
    ?>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Possible Duplicate: Why does C++ not let baseclasses implement a derived class' inherited interface?
Possible Duplicate: Why does an overridden function in the derived class hide other overloads
Possible Duplicate: Where and why do I have to put the “template” and “typename”
Possible Duplicate: overloaded functions are hidden in derived class I have Class A and
Possible Duplicate: Casting List<> of Derived class to List<> of base class The title
Possible Duplicate: Accessing protected members in a derived class If I have an abstract
Possible Duplicates: C++ overload resolution Why does an overridden function in the derived class
Possible Duplicate: Printing derived class name in base class I am using GCC, and
Possible Duplicate: overloaded functions are hidden in derived class It seems that I cannot
Possible Duplicate: Is there a way to prevent a class from being derived from

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.