Jump to content

[SOLVED] Objects over multiple pages


jasonlfunk

Recommended Posts

Hello,

I am fairly proficient in PHP as well as understanding Object oriented programming. The tutorials that I can find with google talk about oop on a single page. The application that I am designing is very clean in with OO design but I cannot quite get it straight in my mind how the objects are retained throughout various pages. The objects are going to be created/filled with data from a database and it seems like too much overhead to reconstruct these objects for every page. From what i have picked up by browsing these forms is that it is standard practice to save objects in sessions, or serialize them or something. Is there good documentation or a tutorial somewhere that explains the concepts behind this?

Link to comment
https://forums.phpfreaks.com/topic/59709-solved-objects-over-multiple-pages/
Share on other sites

http://www.phpfreaks.com/forums/index.php/topic,149316.0.html

 

<?php
include('class.def.php'); // has to be before session_Start
session_start();

if (!isset($_SESSION['class_name'])) {
       $_SESSION['class_name'] = new class_name();
}else {
   $x=1;
}
$class &= $_SESSION['class_name']; // dunno if keeping the reference works but yea

if ($x==1)
    echo $class->get_var('test');

$class->set_var('test', 'Testing');

$_SESSION['class_name'] = $class;
?>

 

Unsure how savory that is, efficient or how much a toll it would take on the server. But yea I think that is what you are looking for.

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.