I am new in OOP with PHP and I’m trying to do something like this:
Class entry form is inside it’s own file.
index.php creates an object from class entry form and stores it in session.
page1.php – I want to be able to call this object back and run some methods on it to modify it’s values. Except this is not working…
So the work flow is as follows
index->page1
I’m trying to grasp the concept of object orriented programming. And i’m starting to get it.
Is what I’m trying to do wrong? is this possible?
//page1.php
include('entry.class.php');
session_start();
print_r($_SESSION['entry']);
$entry = unserialize($_SESSION['Entry']);
$entry->set_category('Asian');
$entry->set_upload('http://paypal.com');
print_r($entry);
//index.php
session_start();
include('entry.class.php');
$entry = new entryForm();
$entry->set_category('Blondes');
$entry->set_upload('http://google.com');
$_SESSION['entry'] = serialize($entry);
print_r($entry);
print_r($_SESSION['entry']);
//class entryform
class entryForm{
var $category;
var $upload;
function set_category($new_category)
{
$this->category = $new_category;
}
function get_category()
{
return $this->category;
}
function set_upload($new_upload)
{
$this->upload = $new_upload;
}
function get_upload()
{
return $this->upload;
}
}
in your unserialize you wrote the ‘Entry’ Uppercase. while in the serialize you wrote ‘entry’, lowercase