PHP class function call

Posted on 2005-04-07
Last Modified: 2006-11-18
----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

echo getName($table_info[1]));

----The output is an error messege: undefined function getName().  
Question by:jabootyboy
    LVL 14

    Expert Comment

    i think all you are missing the the "new" keyword

    $table_info= new table_info();
    LVL 1

    Accepted Solution

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

    Featured Post

    What Should I Do With This Threat Intelligence?

    Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

    Join & Write a Comment

    Author Note: Since this E-E article was originally written, years ago, formal testing has come into common use in the world of PHP.  PHPUnit ( and similar technologies have enjoyed wide adoption, making it possib…
    Using SQL Scripts we can save all the SQL queries as files that we use very frequently on our database later point of time. This is one of the feature present under SQL Workshop in Oracle Application Express.
    Viewers will get an overview of the benefits and risks of using Bitcoin to accept payments. What Bitcoin is: Legality: Risks: Benefits: Which businesses are best suited?: Other things you should know: How to get started:
    The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

    732 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    22 Experts available now in Live!

    Get 1:1 Help Now