hosted by liquidweb


Go Back   Web Hosting Talk : Web Hosting Main Forums : Programming Discussion : PHP save values in classes from page to page
Reply

Forum Jump

PHP save values in classes from page to page

Reply Post New Thread In Programming Discussion Subscription
 
Send news tip View All Posts Thread Tools Search this Thread Display Modes
  #1  
Old 02-23-2005, 02:09 PM
TranceNote TranceNote is offline
New Member
 
Join Date: Feb 2005
Posts: 4

PHP save values in classes from page to page


Hello!

I have just started to use classesin php, I did this because I wanted my webbapplikation to work more like a ordinary software.

Now im trying to figure how I should make the variables keep their values from page to page,

Ive read on php.net that I can use session_register() for this, and that I can save a whole class in with this. But how do I "extract" it from the session afterwards?

for example I got this class:

PHP Code:
class test {

         var 
$test1;
         var 
$test2;

          function 
write() {
                      
$this->test1 += 1;
                      
$this->test2 += 1;
                      echo 
"$this->test1 and $this->test2";

          }

I call for the function write

$this->write();

and then I call for it once again but later on another page
Now I want it to output "2 and 2" not "1 and 1"

I dont know more how I can explain it, can someone help me on this, or show an example how you save the class in a session and can use its methods on other pages (I know I have to include the class on all pages) with the values left.

Best Regards



Sponsored Links
  #2  
Old 02-23-2005, 02:48 PM
assistanz247 assistanz247 is offline
Web Hosting Master
 
Join Date: Nov 2004
Location: India
Posts: 1,083
Hi,

You have to call the function session_start() on the second page, and then you can retrieve the values you stored in session variable by simply specifying the variable name.

__________________
AssistanZ - Beyond Boundaries...
Cloudstack Consultancy / 24x7 Web Hosting Support / 24x7 Server Management / Infrastructure Management Services
Web & Mobile Apps Development / Web Designing Services / Php, Grails, Java Development


  #3  
Old 02-23-2005, 03:04 PM
TranceNote TranceNote is offline
New Member
 
Join Date: Feb 2005
Posts: 4
Quote:
Originally posted by techlollu
Hi,

You have to call the function session_start() on the second page, and then you can retrieve the values you stored in session variable by simply specifying the variable name.
Gaah stupid me, I used session_start() but I re-declared the variable =)

Thank you!

Sponsored Links
Reply

Related posts from TheWhir.com
Title Type Date Posted
Web Hosting Sales and Promos Roundup – April 11, 2014 Web Hosting News 2014-04-11 14:59:29
Ads Available for the Second Printing of WHIR’s Annual Hottest Hosts Directory Blog 2014-04-08 16:52:36
Page.ly Grows Managed WordPress Hosting Platform with BlogDroid Acquisition Web Hosting News 2013-06-27 15:43:37
Google Launches Open Source Apache HTTP Server Module mod_pagespeed Web Hosting News 2012-10-12 12:01:56
Users Still Seek Hosting Alternatives as Apple MobileMe, iWeb Shut Off Saturday Web Hosting News 2012-06-29 13:52:54


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes
Postbit Selector

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump
Login:
Log in with your username and password
Username:
Password:



Forgot Password?
Advertisement:
Web Hosting News:



 

X

Welcome to WebHostingTalk.com

Create your username to jump into the discussion!

WebHostingTalk.com is the largest, most influentual web hosting community on the Internet. Join us by filling in the form below.


(4 digit year)

Already a member?