• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 4398
  • Last Modified:

PHP class function call

----I have a php class:  

class Table {

var $name, $postion;

function Table($name, $postion){

$this->name = $name;
$this->postion = $postion;
}

function getName(){
return $this->name;
}


function getPostion(){
return $this->postion;
}

}



----and have a array with the class objects

function table_info(){
$table_info[0] = new Table("location",0);
$table_info[1] = new Table("competition",1);
$table_info[2] = new Table("design",2);
$table_info[3] = new Table("economic_conditions",3);
$table_info[4] = new Table("projections",4);
$table_info[5] = new Table("restaurant",5);
$table_info[6] = new Table("service",6);
$table_info[7] = new Table("floor",7);
$table_info[8] = new Table("bar",8);
$table_info[9] = new Table("submit",9);
return $table_info;
}      



-----And am trying to return the a Table objects name, with getName() in the table class

$table_info=table_info();
echo getName($table_info[1]));

----The output is an error messege: undefined function getName().  
0
jabootyboy
Asked:
jabootyboy
1 Solution
 
dfu23Commented:
i think all you are missing the the "new" keyword

$table_info= new table_info();
0
 
tayduiCommented:
You have to write as following:
 $table_info=table_info();
 echo $table_info[1]->getName();
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now