hosted by liquidweb


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

Programming Discussion Discussions related to web programming languages and other related issues. Topics may include configuration, optimization, practical usage and database connectivity.
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

Reply With Quote


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,069
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.

__________________
Outsourced Webhosting Support / cPanel Server Management Since 2004
Technical Support / Web Development / Billing Support

Reply With Quote
  #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!

Reply With Quote
Sponsored Links
Reply

Related posts from TheWhir.com
Title Type Date Posted
Google Launches Open Source Apache HTTP Server Module mod_pagespeed Web Hosting News 2012-10-12 12:01:56
Web Host ServInt Encourages Community Work with Customer Charity Award Web Hosting News 2012-03-08 11:12:54
New on WHIR TV – Christian Dawson Discusses the “Save Hosting” Group Blog 2011-09-13 21:41:42
Q&A: Rackspace’s Mark Collier on OpenStack Cloud Builders Web Hosting News 2011-09-01 14:48:51
HostUCan Releases Hosting Relevancy Analysis Tool for Website Owners Web Hosting News 2011-07-11 14:52:36


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?