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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T10:19:10+00:00 2026-05-23T10:19:10+00:00

I have like: class Class2 extends Class1 { ….. function __construct() { parent::__construct(); $var_in_included_file;

  • 0

I have like:

class Class2 extends Class1 {
.....
 function __construct() {
 parent::__construct();
   $var_in_included_file;
}   
}

class Class1 {
function __construct() {
 include_once('my_file.php')
}
.....
}

my_file.php:

$var_in_included_file=10;

The problem is that I cannot receive value of $var_in_included_file. Is there a way to receive this value without add many codice like:

$this->var=$var_in_included_file ....? 

Because I have many thousands of variables.
Thanks.
More abstract the problem is:
in some file I received (from $_POST) near 500 variable.
These variables have be elaborated in complicated way. For simplify this elaborating I need create tree of class inheritans – but in this case these variables will not seen in child classes without assigning them to class variables – but this produses enormous volume of code.

  • 1 1 Answer
  • 1 View
  • 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-23T10:19:10+00:00Added an answer on May 23, 2026 at 10:19 am

    As explained in include() and variable scopes, when you include a file in your __construct() method, the scope of the variables in the file you’re including is limited to the __construct() method, not the class.

    Your options would be to either change the content of the included file to include a $this-> in front of the variable name (i.e. $this->var_in_included_file = 10;) or add a $this->var_in_included_file = $var_in_included_file; in your __construct() method.

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

Sidebar

Related Questions

i have a class like: class List_PendingVerify extends Rs_List { public function __construct( $id
I have a class like: class bla_bla extends WP_Widget { function boo(){ return 'something';
I have a parent class containing a function funcB() which I like to override
here is what my code looks like i have two forms: class Form_1 extends
I have a custom-made view that extends the View class. I would like 2
If I have code like so: class X extends JFrame { X() { setLayout(new
I have something like: class A { } class B extends A { }
I have code like this: class ToBeTested { function simpleMethod($param) { if(0 === $param)
I have code like: class Entity; class EntityTool extends Entity; class EntitySprite extends Entity;
I have a class like this: class A { public $var = ; function

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.