Codeasearch.com - Search your code with us Login | Register | Contact us
  Forums > Php > hi need help in class
damodharan
Posted on Nov 18, 2008
Join Date: November 2008
Location: India ( chennai )
Posts: 1
 
hi need help in class  

class damu()
{
function one()
{
return $name = "damu";
}
}
=======================
class dharan extends damu()
{

function myname ()
{

$myname = $this->one();
}

function myname2()
{

}
}
ithula
function name2

gurusharan
Posted on Nov 30, 2008
Join Date: November 2008
Location: India ( Chennai )
Posts: 2
 
RE : hi need help in class  

You need to specify the class visibility mode or access specifier (private/protected/public). The default (one which is used when nothing is provided as in your case) specifier used is "private". Hence the function can't be used outside the class, even in inherited. You should use either protected (inherited class) or public (to access from anywhere).

benaya
Posted on Nov 18, 2008
Join Date: June 2007
Location: India ( Chennai )
Posts: 90
 
RE : hi need help in class  

Hi,
you can do like this.

class damu
{
public function one()
{
return $name = "damu";
}
}
//=======================
class dharan extends damu
{
function myname ()
{
return $myname = $this->one();
}

function myname2()
{

}
}

$objdharan = new dharan;
echo $objdharan->myname();

 Hot Discussion
Go Tech launches Android tablet for Rs 3,999...
Sony targets retailers with quick sales pitches and rew...
Share and discover new activities with Google Schemer...
Samsung gets 9 mn preorders for Galaxy S3: Report...
Google revamps search engine to think like a person...
 
 Discussion Topics
IT News
Php
Javascript
Technology Updates
Asp.Net
MySql
Ajax
Html
Fedora
Software Testing
Asp
Java
General
Flash
Ruby on Rails