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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T08:49:59+00:00 2026-06-10T08:49:59+00:00

Righty-o I am fairly new to OOP. Im using PHP v5+ I have my

  • 0

Righty-o

I am fairly new to OOP.

Im using PHP v5+

I have my index.php:

<?
include_once('class/includes.php');
$reg = new register;
$action = $_GET['action'];
$page = $_GET['page'];
include('header.php');
if($page):
include($page);
else:
include('home.php');
endif;
include('footer.php');
?>

i have my htaccess set up so that the url for each page is foo.com/pagename

Thats fine.

on my classes.php page (foo.com/classes) which as default includes viewClasses.php
//note classes refers to yoga classes rather than OOP classes

so essentially i have 2 levels of includes (index.php including classes.php which includes viewClass.php)

this is my viewClass.php

<?
global $reg;
$reg->viewClassList();
echo $reg->classList;

?>

For some reason it is not picking up $reg as defined in index.php and therefore is giving me this error:

Fatal error: Call to a member function viewClassList() on a non-object in /home/pandazco/public_html/register/viewClass.php on line 3

I hope this explains my problem well enough…

  • 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-10T08:50:00+00:00Added an answer on June 10, 2026 at 8:50 am

    The problem appears to be that you are not including the instantiation in your viewClass.php which means that $reg is nothing. This is what the error is telling you.

    However I would never use global vars, in fact I am pretty sure there are many lengthy discussions on not using them. Instead I would set a session variable and read from this instead if you need to pass data between different php scripts.

    Additionally why are you using $reg as a global anyway? All you appear to do is instantiate it in index.php and try to call it in viewClass.php. What are you trying to achieve exactly?

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

Sidebar

Related Questions

I'm fairly new to ggplot. I have made a bumpplot using code posted below.
I'm fairly new to PHP so I have a small problem as I'm learning:
Right now, I have: RewriteRule ^([^/\.]+)?$ index.php?id=$1 [L] to match any username at the
I'm fairly new to Visual Studio (specifically Visual Basic .NET) but have been programming
I'm fairly new to using AJAX in ASP.NET (although I am very familiar with
I am fairly new to C#, and have just dug in. I got my
I am fairly new to PHP and mysql and was wondering if I could
I am fairly new to openGL. I have a 3d game that I have
Still fairly new to android, wondered if anyone can help... I have an App
I'm fairly new to jQuery and I'm using the script below. Basically it uses

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.