Dev Shed Lounge
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsOtherDev Shed Lounge

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old June 18th, 2003, 05:25 PM
esha esha is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2003
Location: USA
Posts: 17 esha User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
classes and array declaration problem

I made a normal slide out menu in javascript.
Now i am using php to make sure i can put it on all pages and all.

so I made a class called menu item.
<? php

class menuitem
{
var $name; //name
$submenu = array();//array of submenu items.
var $link; //link
var $currentposition;
var $id
var $linkinfo;

function menuitem($name, $submenu, $link,$prevposition,$id,$linkinfo)
{
$this->name = $name;
$this->link = $link;
for($i =0; $i<submenu; i++)
{
$this->submenu[i] = new submenuitem(""," ");
}
$this->currentposition = $prevposition + 40;
$this->id =$id;
$this->linkinfo;
}

function getposition()
{
return $this->currentpostion;
}

function ypslideout()
{
$size = 50*sizeof($this->submenu);
print("new ypSlideOutMenu(\"$this->name\"".", \"right\", 120,$this->currentposition , 150, $size);\n");
}

function link()
{
print("<a id=\"$this->id\""." href=\"$this->link\""." onmouseover=\"ypSlideOutMenu.showMenu(\'$this->name\')\""." onmouseout=\"ypSlideOutMenu.hideMenu(\'$this->name\')\">"."$linkinfo"."</a><br>\n");
print("<br>");
}

function submenulink($array, $name, $link)
{
$this->submenu[$array]->setlink($name, $link);

}

function createsubmenu()
{
if(sizeof($this->submenu)!=0)
{
$divid1 = $name."container";
$divid2 = $name."content";
print("<div id = \"$divid1\">\n");
print(" <div id=\"$divid2\"." class=\"menu\">\n");
print(" <div class=\"options\">\n");
for(int i = 0;
print(" <a href="$this->submenu[i]->getlink()"".">$this->submenu[i]->getname()</a>\n");
print(" </div>\n");
print(" </div>\n)";
}
}?>

now i am getting a parse error on line 3. I wonder if something is wont with my array declaration.

Last edited by esha : June 19th, 2003 at 10:01 AM.

Reply With Quote
  #2  
Old June 18th, 2003, 05:54 PM
Ctb's Avatar
Ctb Ctb is offline
An Ominous Coward
Dev Shed Specialist (4000 - 4499 posts)
 
Join Date: Jan 2002
Posts: 4,425 Ctb User rank is Colonel (50000 - 60000 Reputation Level)Ctb User rank is Colonel (50000 - 60000 Reputation Level)Ctb User rank is Colonel (50000 - 60000 Reputation Level)Ctb User rank is Colonel (50000 - 60000 Reputation Level)Ctb User rank is Colonel (50000 - 60000 Reputation Level)Ctb User rank is Colonel (50000 - 60000 Reputation Level)Ctb User rank is Colonel (50000 - 60000 Reputation Level)Ctb User rank is Colonel (50000 - 60000 Reputation Level)Ctb User rank is Colonel (50000 - 60000 Reputation Level)Ctb User rank is Colonel (50000 - 60000 Reputation Level)Ctb User rank is Colonel (50000 - 60000 Reputation Level)Ctb User rank is Colonel (50000 - 60000 Reputation Level) 
Time spent in forums: 3 Weeks 10 h
Reputation Power: 0
Put your code in PHP tags so folks can actually read it while you're at it...

Reply With Quote
  #3  
Old June 19th, 2003, 12:03 AM
MJEggertson MJEggertson is offline
Contributing User
Dev Shed Novice (500 - 999 posts)
 
Join Date: Jan 2002
Location: Seattle WA
Posts: 863 MJEggertson User rank is Corporal (100 - 500 Reputation Level)MJEggertson User rank is Corporal (100 - 500 Reputation Level)MJEggertson User rank is Corporal (100 - 500 Reputation Level)MJEggertson User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: 22 sec
Reputation Power: 8
You're mixing your javascript and php code. Take a closer look at line three. There's only two 'words'...php doesn't have a var statement.

Reply With Quote
  #4  
Old June 19th, 2003, 12:08 AM
jpenn's Avatar
jpenn jpenn is offline
Contributing User
Dev Shed Frequenter (2500 - 2999 posts)
 
Join Date: Jun 2002
Location: Washington, DC
Posts: 2,693 jpenn User rank is Sergeant (500 - 2000 Reputation Level)jpenn User rank is Sergeant (500 - 2000 Reputation Level)jpenn User rank is Sergeant (500 - 2000 Reputation Level)jpenn User rank is Sergeant (500 - 2000 Reputation Level)jpenn User rank is Sergeant (500 - 2000 Reputation Level) 
Time spent in forums: 5 h 41 m 10 sec
Reputation Power: 16
Quote:
There's only two 'words'...php doesn't have a var statement.

Actually - it does, he/she is intializing/defineing the attributes, thats how to do it in php.

The problem is initializing the att to array() - initialize it to nothing then asign it in the constructor...

Reply With Quote
  #5  
Old June 19th, 2003, 10:02 AM
esha esha is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2003
Location: USA
Posts: 17 esha User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
can you please rexplain this to me?
I am not understanding.

Reply With Quote
  #6  
Old June 19th, 2003, 10:31 AM
karsh44's Avatar
karsh44 karsh44 is offline
Just another guy
Dev Shed Frequenter (2500 - 2999 posts)
 
Join Date: Jun 2003
Location: Wisconsin
Posts: 2,915 karsh44 User rank is Second Lieutenant (5000 - 10000 Reputation Level)karsh44 User rank is Second Lieutenant (5000 - 10000 Reputation Level)karsh44 User rank is Second Lieutenant (5000 - 10000 Reputation Level)karsh44 User rank is Second Lieutenant (5000 - 10000 Reputation Level)karsh44 User rank is Second Lieutenant (5000 - 10000 Reputation Level)karsh44 User rank is Second Lieutenant (5000 - 10000 Reputation Level)karsh44 User rank is Second Lieutenant (5000 - 10000 Reputation Level) 
Time spent in forums: 1 Week 6 Days 13 h 13 m 21 sec
Reputation Power: 76
The explaination is to move your question to the PHP forum, and everything will work again

Reply With Quote
  #7  
Old June 19th, 2003, 11:52 AM
MJEggertson MJEggertson is offline
Contributing User
Dev Shed Novice (500 - 999 posts)
 
Join Date: Jan 2002
Location: Seattle WA
Posts: 863 MJEggertson User rank is Corporal (100 - 500 Reputation Level)MJEggertson User rank is Corporal (100 - 500 Reputation Level)MJEggertson User rank is Corporal (100 - 500 Reputation Level)MJEggertson User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: 22 sec
Reputation Power: 8
Crap. Don't post on your birthday when you get back from the bar...

Reply With Quote
Reply

Viewing: Dev Shed ForumsOtherDev Shed Lounge > classes and array declaration problem


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 3 hosted by Hostway