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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T09:35:10+00:00 2026-05-26T09:35:10+00:00

I’m relatively new to PHP OOP and cant seem to be able to call

  • 0

I’m relatively new to PHP OOP and cant seem to be able to call functions in a PHP Class via a controller. My current setup is:

  • index.php
  • class.Class1.php
  • functions.controller.php
  • script.js

Within index.php i include class.Class1.php, make a new Class object and use a couple of it’s methods to output some HTML. I want to use js functions in script.js (called by using the onclick attribute of a link) to communicate with functions.controller.php, which in turn will call methods in class.Class1.php and return the data to script.js who will in turn output HTML on index.php.

The problem is that i dont know how to use the methods to get the data of that particular object. When i call the controller:

$.ajax({
    type: 'GET',
    url: 'functions/functions.controller.php',
    data: 'r=' + 'h',
    success: function(data){
        $('.showing').html(data);
    }
});

I get a 500 Internal server error:

[25-Oct-2011 01:24:06] PHP Warning: include(classes/class.Class1.php)
[function.include]: failed to open
stream: No such file or directory in
/Users/Joey/Desktop/root/Test/functions/functions.controller.php on
line 7

[25-Oct-2011 01:24:06] PHP Warning: include() [function.include]: Failed opening
‘classes/class.Class1.php’ for inclusion
(include_path=’.:/Applications/MAMP/bin/php5.3/lib/php’) in
/Users/Joey/Desktop/root/Test/functions/functions.controller.php on
line 7

[25-Oct-2011 01:24:06] PHP Fatal error: Class ‘Class1’ not
found in
/Users/Joey/Desktop/root/Test/functions/functions.controller.php on
line 9

This is controller.php:

include('classes/class.Class1.php');

$in = new Class1;

echo $in->getData();

Can anyone please shed some light on this? Also any other PHP OOP MVC with AJAX tips are welcome. If more of my current code is needed, i’ll be happy to post.

  • 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-05-26T09:35:10+00:00Added an answer on May 26, 2026 at 9:35 am

    Looks like you’re getting your include paths mixed up.

    I’m assuming your file structure is actually

    index.php
    classes/class.Class1.php
    functions/functions.controller.php
    script.js
    

    To include class.Class1.php from functions.controller.php, you need to traverse up a directory first to get out of the functions directory, eg

    // PHP >= 5.3
    require_once __DIR__ . '/../classes/class.Class1.php';
    
    // PHP < 5.3
    require_once dirname(__FILE__) . '/../classes/class.Class1.php`;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I want to count how many characters a certain string has in PHP, but
I would like to count the length of a string with PHP. The string
this is what i have right now Drawing an RSS feed into the php,
I want use html5's new tag to play a wav file (currently only supported
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I'm trying to create an if statement in PHP that prevents a single post
I am doing a simple coin flipping experiment for class that involves flipping a

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.