Jump to content

Class declared, but not seen


ciber

Recommended Posts

Hi,

 

Basically I am going to give a short description to my problem with pseduo and comments (-->), there is too much to paste all my code here:

 

basically

 

include(config.php) --> database connection

include(global.php) --> class is instantiated here as $p ($p is GLOBAL)

 

--> I print_r the $p value here, and it shows (debugging)

switch()

case x:

include file.php;

break;

 

--> but when I try to access it or print_r it here (here being within the file.php), via the file that has been included above "include file.php", it does not see it. I have to re-declare the $p variable with the class, within the included file.

 

any tips as how to solve this please; I dont see why it wouldnt see it, since all the file is that I am including is an HTML file with a few PHP lines, which checks if a user has permission:

if(!$p->check()) redirect("index.php");

Link to comment
Share on other sites

Best guess is you are using a URL in your include statement. That does not include the code in the included file into the current program's scope and so does not make variables in the main program scope available in the included code.

 

Second best guess, you are expecting a main program variable to be available in the local scope of a function definition and they are not.

 

Posting actual code that demonstrates/duplicates the problem is the quickest way of getting help.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.