473,378 Members | 1,571 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

Array Problems

In the code below, the aboutMenuNames array gets overwritten with the
values in mainMenuNames in the constructor. What am I doing wrong?
class dynamicMenu {

var $mainMenuNames;

var $aboutMenuNames;

//
// Constructor
//
function dynamicMenu() {
$this->$aboutMenuNames = array("About Us",
"Statement of Faith",
"About Our Pastor",
"Directions to Us",
"Contact Us");

$this->$mainMenuNames = array("Home",
"AboutUs",
"ForAdults",
"ForTheKids",
"ForTheYouth",
"WantToServe");
}
};

Jul 17 '05 #1
2 1455
On Sat, 13 Nov 2004 12:07:51 -0600, "O.B." <fu******@bellsouth.net> wrote:
In the code below, the aboutMenuNames array gets overwritten with the
values in mainMenuNames in the constructor. What am I doing wrong?
class dynamicMenu {

var $mainMenuNames;

var $aboutMenuNames;

//
// Constructor
//
function dynamicMenu() {
$this->$aboutMenuNames = array("About Us",
"Statement of Faith",
"About Our Pastor",
"Directions to Us",
"Contact Us");

$this->$mainMenuNames = array("Home",
"AboutUs",
"ForAdults",
"ForTheKids",
"ForTheYouth",
"WantToServe");
}
};
You've accidentally used variable variables.

$a = 'b'; // sets $a
$$a = 'c'; // sets $b

$obj->a = 'b'; // sets member variable $a in the object
$obj->$a = 'c'; // sets member variable $b in the object
$this->$aboutMenuNames = ...
$this->$mainMenuNames = ...


Should be:

$this->aboutMenuNames = ...
$this->mainMenuNames = ...

--
Andy Hassall / <an**@andyh.co.uk> / <http://www.andyh.co.uk>
<http://www.andyhsoftware.co.uk/space> Space: disk usage analysis tool
Jul 17 '05 #2
O.B. wrote:
In the code below, the aboutMenuNames array gets overwritten with the
values in mainMenuNames in the constructor. What am I doing wrong?
class dynamicMenu {

var $mainMenuNames;

var $aboutMenuNames;

//
// Constructor
//
function dynamicMenu() {
$this->$aboutMenuNames = array("About Us",
"Statement of Faith",
"About Our Pastor",
"Directions to Us",
"Contact Us");

$this->$mainMenuNames = array("Home",
"AboutUs",
"ForAdults",
"ForTheKids",
"ForTheYouth",
"WantToServe");
}
};


Instead of:
$this->$aboutMenuNames
$this->$mainMenuNames

Write:
$this->aboutMenuNames
$this->mainMenuNames

--
http://area51.cryostudio.net
Jul 17 '05 #3

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

Similar topics

12
by: shailashri_sk | last post by:
Hi, int *p; p++; here p now increments itself with the size of integer. similarly, I wanted to know, how to declare an pointer to an array ( say array of integers) where in it we do a p++ it...
8
by: engaref | last post by:
Hello Every body, I am new with C programming.I have received the Problems from my advisor on Array but I did not find any Proper answer yet. If Possible,please make a solution for the Problems....
204
by: Alexei A. Frounze | last post by:
Hi all, I have a question regarding the gcc behavior (gcc version 3.3.4). On the following test program it emits a warning: #include <stdio.h> int aInt2 = {0,1,2,4,9,16}; int aInt3 =...
16
by: Ekim | last post by:
hello, I'm allocating a byte-Array in C# with byte byteArray = new byte; Now I want to pass this byte-Array to a managed C++-function by reference, so that I'm able to change the content of the...
3
by: Faustino Dina | last post by:
Hi, The following code is from an article published in Informit.com at http://www.informit.com/guides/content.asp?g=dotnet&seqNum=142. The problem is the author says it is not a good idea to...
5
by: Stacey Levine | last post by:
I have a webservice that I wanted to return an ArrayList..Well the service compiles and runs when I have the output defined as ArrayList, but the WSDL defines the output as an Object so I was...
3
by: inkexit | last post by:
I need help figuring out what is wrong with my code. I posted here a few weeks ago with some code about creating self similar melodies in music. The coding style I'm being taught is apparently a...
104
by: Leszek | last post by:
Hi. Is it possible in javascript to operate on an array without knowing how mamy elements it has? What i want to do is sending an array to a script, and this script should add all values from...
152
by: vippstar | last post by:
The subject might be misleading. Regardless, is this code valid: #include <stdio.h> void f(double *p, size_t size) { while(size--) printf("%f\n", *p++); } int main(void) { double array = { {...
5
by: ctj951 | last post by:
I have a very specific question about a language issue that I was hoping to get an answer to. If you allocate a structure that contains an array as a local variable inside a function and return...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?

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.