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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T06:52:39+00:00 2026-06-01T06:52:39+00:00

Here is the class: functions.php class buildPage { public function Set($var,$val){ $this->set->$var = $val;

  • 0

Here is the class:

functions.php

class buildPage {

    public function Set($var,$val){
        $this->set->$var = $val;
    }

    function Body(){
        ob_start();

        include('pages/'.$this->set->pageFile);
        $page = ob_get_contents();

        ob_end_clean();

        return $page;
    }

    function Out(){
        echo $this->Body();
    }
}

So here is the main (index) page of the script.

index.php

include_once('include/functions.php');

$page = new buildPage();

$page->Set('pageTitle','Old Title');    
$page->Set('pageFile','about.php');

$page->Out();

Now as you can see, it includes about.php file through class, actually inside the class.

And now, I want to access the same buildPage() class to change the page title.

about.php

<?php

$this->Set('pageTitle','New Title');
echo '<h1>About Us</h1>';

?>

But unfortunately, nothing happens.

Please be kind to take few minutes to give me some 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-01T06:52:41+00:00Added an answer on June 1, 2026 at 6:52 am

    OK. I’ve managed to fix the problem myself.

    Changed function Body() and Out() as follows :

    function Body(){
    
        $pageFile = $this->Get('pageFile');
        if(empty($pageFile)){
            $pageFile = 'home.php';
        }
    
        $page_path = 'pages/'.$pageFile;
    
        ob_start();
    
        include($page_path);
    
        if(!empty($page_set_arr) && is_array($page_set_arr)){
            foreach($page_set_arr AS $k=>$v){
                $this->Set($k,$v);
            }
        }
    
        $page = ob_get_clean();
    
        return $page;
    }
    
    function Out(){
        $body = $this->Body();
    
        echo $this->Header();
        echo $body;
        echo $this->Footer();
    }
    

    And then changed the file about.php as follows :

    <?php
    
    $page_set_arr = array(
                        'pageTitle' => 'About Us'
                    );
    
    ?>
    
    <h1>About Us</h1>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Here's my Zend code: <?php require_once ('Zend\Form.php'); class Sergio_Form_registrationform extends Zend_Form { public function
Here is some code: var class = function(elem,div){ this.elem= elem; this.div = div; this.init
In here, http://jsfiddle.net/sjKgF/78/ JS CODE $('.display_box').hover(function (){ $(this).attr('class', 'display_box current') }, function (){ $(this).attr('class',
So I have this class: class A{ public function do_a(){ return 'a_done';}; public function
Here is my helper class class Zend_View_Helper_CommonArea extends Zend_View_Helper_Abstract { public function commonArea() {
<?php class MY_Form_validation extends CI_Form_validation { function My_Form_validation() { parent::CI_Form_validation(); } } This is
<?php class a { public function foo() { echo __METHOD__ . PHP_EOL; } }
Here is the textbook standard way of describing a 'class' or constructor function in
i need a Function Pointer from a base class. Here is the code: class
I found this code here class Usable; class Usable_lock { friend class Usable; private:

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.