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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T01:56:03+00:00 2026-06-05T01:56:03+00:00

I have an index.php that loads bites of the page from other php files.

  • 0

I have an index.php that loads bites of the page from other php files. At the top of the index.php I have all the require_once statements including the PHP class that handles the db connection and I also instantiate an object of that class:

<?php 
    require_once 'libs/DatabaseHandler.php';

    $dbh = new DatabaseHandler('localhost', 'root', '*******', 'pride2012');

    require_once 'pages/01_includes.php';
    require_once 'pages/02_menu.php';
    require_once 'pages/03_slider.php';
    require_once 'pages/04_news.php';   
?> 

The page-bit using the db managing class is 04_news.php, is it enough constructing the object before 04_news.php loads to make myself sure that the object exists before the database related operations start?

  • 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-05T01:56:05+00:00Added an answer on June 5, 2026 at 1:56 am

    Defining the object prior to the operations is enough.

    Alternatively, you can use the built-in __autoload( ) method to dynamically load classes as needed.

    Take a look at PHP.net: Autoloading Classes for more information.

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

Sidebar

Related Questions

I have an index.php file that loads other php files via this javascript/ajax code:
I have a index.php page that is the main page. All pages are included
I have a page index.php that uses a modal to upload files. After those
I have an ajax script, in the main index.php page, that fetches data from
I have a index.php file that will include several external files: content/templates/id1/template.php content/templates/id2/template.php content/templates/id3/template.php
i have a question, i have a index.php page that is the intro of
I have a function that I use on index.php page and I would like
Assume that I have 2 .php files : index.php and ajax.php This is index.php:
I have built a webpage, splashcreen.html , that when someone loads index.php will automatically
I have a php file that loads an article from a db based on

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.