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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T01:28:58+00:00 2026-06-08T01:28:58+00:00

I have two files say file1.php and file2.php. I have one php file named

  • 0

I have two files say file1.php and file2.php. I have one php file named form in which class form has been defined.
I have created an object in file1.php as follow:

require_once('form.php');
$x=$_GET['field'];
$form = new Form("", ""); 
$personal = new Block("");

$address = new TextArea("address", $x, "", 3, 30); 
$personal->add($address);
$form->add($personal);
echo $form;

now i want to use this object $form and $personal in another file file2.php which is as follow:

$personal = new Block("");
$name = new Text("name",$x);
$personal->add($name);
$form->add($personal);
echo $form;

how can i use these objects in php. please help.

  • 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-08T01:29:00+00:00Added an answer on June 8, 2026 at 1:29 am

    If you include one PHP file into the other, there is no problem, as the code in both will get merged to the scope of the including code.

    Otherwise, if you wish to us re-use the objects at different positions in your code, you can use a registry (see also: How is testing the registry pattern or singleton hard in PHP?) to store the instantiated object.

    If you plan to re-use the same objects on the next page load you need to serialize them, store the serialized object in the session/cache (or elsewhere) and unserialize it after loading the next page. In that case you’ll also need some mechanism to set up a database connection or perform other required tasks (see: __wakeup()).

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

Sidebar

Related Questions

Say I have two files where there is one number per line File 1
Let's say that I have a file (file1.php) with a simple form with the
I have two files client.php and server.php. The client file send a HTTP request
I have two files: domainList and config.cnf. The domainList file simply has a list
I'm stumped! In PHP in Netbeans (6.8), a project has two files, file1.php and
I have two files. First one has 482 lines. Second one has only 519
Say I have file.php with three functions and an echo statement: function one() {
Suppose I have two url for the same file, say http://site.com/fr/page.php and http://site.com/en/page.php .
Let's say I have two files default.aspx and the associated default.aspx.cs . default.aspx.cs: protected
Lets say i have at least two lua script files. test1.lua test2.lua both define

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.