473,770 Members | 1,939 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Class variable problem

Hello,

I have this class http://pastebin.com/807571, where I set some variables on
__construct. Originaly I set the $total_? variables when the function
showLayout() was called. I know pastebin is having problems, so if you can't
get the code, I will upload it in plain text on my own server.
This function is called from a page object, which is called from a
controller and so on.
Doing it this way meant that all variables set during the showLayout()
function, were set to null, next time I opened the object.
Then I set it up like it is now, where I set all call variables doring
__construct and this worked fine.
But now the problem is, that the last values added to the class variables
from the showLayout() function are not added.

Is this a bug in PHP5 or am I doing something terribly wrong here?

Best regards, tatsudoshi
Oct 16 '06 #1
15 1481
I have uploaded the class at http://www.criion.net/class.Kurv.php.txt
Oct 16 '06 #2
tatsudoshi wrote:
Hello,

I have this class http://pastebin.com/807571, where I set some variables on
__construct. Originaly I set the $total_? variables when the function
showLayout() was called. I know pastebin is having problems, so if you can't
get the code, I will upload it in plain text on my own server.
This function is called from a page object, which is called from a
controller and so on.
Doing it this way meant that all variables set during the showLayout()
function, were set to null, next time I opened the object.
Then I set it up like it is now, where I set all call variables doring
__construct and this worked fine.
But now the problem is, that the last values added to the class variables
from the showLayout() function are not added.

Is this a bug in PHP5 or am I doing something terribly wrong here?

Best regards, tatsudoshi

You'll need to be more explicit about what you're expecting to see, and
what you are seeing.

I thought it might be a problem with references (in PHP5 Objects are
copied by references, but arrays are not) but I can't see a place where
you're assigning to a copied array, so it doesn't appear to be that.

Colin
Oct 16 '06 #3
tatsudoshi wrote:
Hello,

I have this class http://pastebin.com/807571, where I set some variables on
__construct. Originaly I set the $total_? variables when the function
showLayout() was called. I know pastebin is having problems, so if you can't
get the code, I will upload it in plain text on my own server.
This function is called from a page object, which is called from a
controller and so on.
Doing it this way meant that all variables set during the showLayout()
function, were set to null, next time I opened the object.
Then I set it up like it is now, where I set all call variables doring
__construct and this worked fine.
But now the problem is, that the last values added to the class variables
from the showLayout() function are not added.

Is this a bug in PHP5 or am I doing something terribly wrong here?

Best regards, tatsudoshi

The real question here is - how are you opening the object? Are you
creating a second object or are you referencing the existing object.

The code you're using to access it is also very important.

--
=============== ===
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attgl obal.net
=============== ===
Oct 17 '06 #4
This is a snip of the code from my controller. Each page has a pagecode,
from which I select a case in a switch structur. On Kurv page, it checks to
see if the object is set, and if, gets the array from the object, otherwise
it creates the array and handles all the array related things. At the end of
the case it does this snip shown.

What it is suppose to do is first check if the useraccount can order the
item the user is trying to order.
That it check to see if the object is set, this time to either add the
array, with the new item or create a Kurv object.

I save all objects in SESSION.

if($wrong_user_ account) {
$output = <<<hds
<div id='generic-content'>
<p>Denne type abonnement, kan ikke bestilles med denne konto.</p>
</div
hds;
$obj_kurv_go = new GenericOutput($ output);
}
elseif(isset($t his->obj_kurv)) {
$this->obj_kurv->setArray($arra y);
if(array_key_ex ists("action", $_GET) && $_GET["action"] !=
"add_to_bas ket"
|| array_key_exist s("tilbud_id" , $_GET))
$this->obj_kurv->storeLinkBack( $_SERVER["HTTP_REFER ER"]);

$obj_kurv_go = $this->obj_kurv;
}
else {
$link_to_basket = $this->readPage(array ("mapr" ="byCode",
"sql_id" ="p_kurv_liste" ))->getPageId();
$link_to_bestil = $this->readPage(array ("mapr" ="byCode",
"sql_id" ="p_bestil_1 "))->getPageId();
$link_to_teleca re = $this->readPage(array ("mapr" ="byCode",
"sql_id" ="p_telecare "))->getPageId();

$this->obj_kurv = new Kurv($array, $link_to_basket );
$this->obj_kurv->storeLinkBack( $_SERVER["HTTP_REFER ER"]);
$this->obj_kurv->storeLinkToBes til($link_to_be stil);
$this->obj_kurv->storeLinkToTel ecare($link_to_ telecare);
$obj_kurv_go = $this->obj_kurv;
}
}
$contents["gen_out"] = array($obj_kurv _go);
Oct 17 '06 #5
Hello,

I have this class http://pastebin.com/807571, where I set some variables on
__construct. Originaly I set the $total_? variables when the function
showLayout() was called. I know pastebin is having problems, so if you can't
get the code, I will upload it in plain text on my own server.
This function is called from a page object, which is called from a
controller and so on.
Doing it this way meant that all variables set during the showLayout()
function, were set to null, next time I opened the object.
Then I set it up like it is now, where I set all call variables doring
__construct and this worked fine.
But now the problem is, that the last values added to the class variables
from the showLayout() function are not added.

Is this a bug in PHP5 or am I doing something terribly wrong here?

Best regards, tatsudoshi

Added:
I have uploaded the class at http://www.criion.net/class.Kurv.php.txt

Added:
This is a snip of the code from my controller. Each page has a pagecode,
from which I select a case in a switch structur. On Kurv page, it checks to
see if the object is set, and if, gets the array from the object, otherwise
it creates the array and handles all the array related things. At the end of
the case it does this snip shown.

What it is suppose to do is first check if the useraccount can order the
item the user is trying to order.
That it check to see if the object is set, this time to either add the
array, with the new item or create a Kurv object.

I save all objects in SESSION.

if($wrong_user_ account) {
$output = <<<hds
<div id='generic-content'>
<p>Denne type abonnement, kan ikke bestilles med denne konto.</p>
</div
hds;
$obj_kurv_go = new GenericOutput($ output);
}
elseif(isset($t his->obj_kurv)) {
$this->obj_kurv->setArray($arra y);
if(array_key_ex ists("action", $_GET) && $_GET["action"] !=
"add_to_bas ket"
|| array_key_exist s("tilbud_id" , $_GET))
$this->obj_kurv->storeLinkBack( $_SERVER["HTTP_REFER ER"]);

$obj_kurv_go = $this->obj_kurv;
}
else {
$link_to_basket = $this->readPage(array ("mapr" ="byCode",
"sql_id" ="p_kurv_liste" ))->getPageId();
$link_to_bestil = $this->readPage(array ("mapr" ="byCode",
"sql_id" ="p_bestil_1 "))->getPageId();
$link_to_teleca re = $this->readPage(array ("mapr" ="byCode",
"sql_id" ="p_telecare "))->getPageId();

$this->obj_kurv = new Kurv($array, $link_to_basket );
$this->obj_kurv->storeLinkBack( $_SERVER["HTTP_REFER ER"]);
$this->obj_kurv->storeLinkToBes til($link_to_be stil);
$this->obj_kurv->storeLinkToTel ecare($link_to_ telecare);
$obj_kurv_go = $this->obj_kurv;
}
}
$contents["gen_out"] = array($obj_kurv _go);
Oct 17 '06 #6
Sorry for messing up the messages. I have never tryed using newsgroups
before.
Is it possible to delete a message from the group?
Oct 17 '06 #7
I am not using references at all, as I have not been able to figure out how
it works in the different versions of PHP.

----- Original Message -----
From: "Colin Fine" <ne**@kindness. demon.co.uk>
Newsgroups: comp.lang.php
Sent: Monday, October 16, 2006 11:48 PM
Subject: Re: Class variable problem

You'll need to be more explicit about what you're expecting to see, and
what you are seeing.

I thought it might be a problem with references (in PHP5 Objects are
copied by references, but arrays are not) but I can't see a place where
you're assigning to a copied array, so it doesn't appear to be that.

Colin

Oct 17 '06 #8
Your ansewer is message Re: Class variable problem : 17-10-2006 08:42
Sorry :-/

----- Original Message -----
From: "Jerry Stuckle" <js*******@attg lobal.net>
Newsgroups: comp.lang.php
Sent: Tuesday, October 17, 2006 4:45 AM
Subject: Re: Class variable problem
The real question here is - how are you opening the object? Are you
creating a second object or are you referencing the existing object.

The code you're using to access it is also very important.

--
=============== ===
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attgl obal.net
=============== ===

Oct 17 '06 #9
tatsudoshi wrote:
Sorry for messing up the messages. I have never tryed using newsgroups
before.
Is it possible to delete a message from the group?

No, you can't delete a message from a newsgroup. It's on hundreds of
servers all over the world.

--
=============== ===
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attgl obal.net
=============== ===
Oct 17 '06 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
2422
by: Gerry Sutton | last post by:
Hi All! I have noticed a strange behavior when using a constant identifier to initialize an instance list variable in a base class and then trying to modifying the list in subclasses by using either the list.extend method or even by having the subclass create a whole new list in the variable. The following example illustrates the situation.
9
4996
by: Banaticus Bart | last post by:
I wrote an abstract base class from which I've derived a few other classes. I'd like to create a base class array where each element is an instance of a derived object. I can create a base class pointer which points to an instance of a derived class, but when I pass that base class pointer into a function, it can't access the derived object's public functions. Although, the base class pointer does call the appropriate virtual function...
7
1824
by: bartek | last post by:
Hello, I've been pondering with this for quite some time now, and finally decided to ask here for suggestions. I'm kind of confused, actually... Maybe I'm thinking too much... Brain dump follows... I need a class to represent a variable, with an associated data type and/or value. Though, I don't want it to be a variant type, and not a
7
1869
by: Ben | last post by:
Hi all, I'm not yet good at thinking the right way in c++ so although I could solve this problem, I'm not sure if they way I'm thinking of is the best way to do it. I need a data type or class or something that can hold either an int, or a float, knows which one it is holding, and will allow me to do comparisons with instances of it without the code which asks for the comparison having to know which one it is. So maybe I could do it...
7
2480
by: Drew McCormack | last post by:
I have a C++ template class which contains a static variable whose construction registers the class with a map. Something like this: template <typename T> class M { static Registrar<M> registrar; }; The constructor of Registrar does the registering when it is initialized.
166
8673
by: Graham | last post by:
This has to do with class variables and instances variables. Given the following: <code> class _class: var = 0 #rest of the class
6
1914
by: Vladislav Kosev | last post by:
I have this strange problem now twice: I am writing this relatevely large web site on 2.0 and I made a static class, which I use for url encoding and deconding (for remapping purposes). This static class needs the session context to encode a url (because I stored the current language there), so I made a static field of type HttpContext, which I refresh every reqest by assigning the current context. Now, every now and then I get this...
9
8895
by: Jess | last post by:
Hello, I was told that if I declare a static class constant like this: class A{ static const int x = 10; }; then the above statement is a declaration rather than a definition. As I've *defined* "x"'s value to be 10, isn't above statement a
5
1521
by: tshad | last post by:
In VS 2003, I am setting up an abstract class that is setting up classes for each datatype of VB.Net (as well as C#). I am trying to set it up so that most of the work is done in the Abstract Class. It seems to work pretty well. I have the actual data memory variables stored as an object as each class will use it as a different type of object (not sure if this is a problem). The system can tell if the variable is a string, boolean or...
20
4043
by: tshad | last post by:
Using VS 2003, I am trying to take a class that I created to create new variable types to handle nulls and track changes to standard variable types. This is for use with database variables. This tells me if a variable has changed, give me the original and current value, and whether the current value and original value is/was null or not. This one works fine but is recreating the same methods over and over for each variable type. ...
0
9592
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9425
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10231
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10005
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8887
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7416
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5452
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3576
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2817
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.