Comment on Tutorial - public, protected, and private Properties in PHP By Andi, Stig and Derick
Comment Added by : Neeraj
Comment Added at : 2010-10-22 07:23:56
Comment on Tutorial : public, protected, and private Properties in PHP By Andi, Stig and Derick
i disagree that private variables can be accessed from derived class. The below code runs perfectly.
<?php
class a{
private $name;
public function setval($val){
$this->name = $val;
echo $this->name." 1<BR>";
}
}
class b extends a{
private $name1;
public function setval($val){
$this->name = $val;
echo $this->name." 2<BR>";
}
}
class c extends b{
private $name2;
public function setval($val){
$this->name = $val;
echo $this->name." 3<BR>";
}
}
class d extends c{
private $name3;
public function setval($val){
$this->name = $val;
echo $this->name." 4<BR>";
}
}
$obj1 = new a();
$obj1->setval(5);
$obj2 = new b();
$obj2->setval(10);
$obj3 = new c();
$obj3->setval(20);
$obj4 = new d();
$obj4->setval(30);
?>
View Tutorial
- Data Science
- Android
- AJAX
- ASP.net
- C
- C++
- C#
- Cocoa
- Cloud Computing
- HTML5
- Java
- Javascript
- JSF
- JSP
- J2ME
- Java Beans
- EJB
- JDBC
- Linux
- Mac OS X
- iPhone
- MySQL
- Office 365
- Perl
- PHP
- Python
- Ruby
- VB.net
- Hibernate
- Struts
- SAP
- Trends
- Tech Reviews
- WebServices
- XML
- Certification
- Interview
categories
Subscribe to Tutorials
Related Tutorials
Program using concept of byte long short and int in java
Update contents of a file within a jar file
Tomcat and httpd configured in port 8080 and 80
Count number of vowels, consonants and digits in a String in Java
Student marks calculation program in Java
Calculate gross salary in Java
Calculate average sale of the week in Java
Vector in Java - Sample Program
MultiLevel Inheritance sample in Java
Archived Comments
1. I have a small query: Is it interface allow method
View Tutorial By: vijay at 2012-04-20 10:34:30
2. hi can u send me the complete working code for sen
View Tutorial By: gautami at 2007-12-04 01:13:45
3. how to get this list to be alphabetically correct?
View Tutorial By: Vincent at 2011-06-14 07:36:58
4. hi,
can you send me more examples regarding
View Tutorial By: Ram M at 2015-10-05 06:32:27
5. hello, that was very useful
but i have a by
View Tutorial By: echo at 2011-04-05 11:50:41
6. nicely explained :)
View Tutorial By: ibtisam at 2012-04-26 10:31:58
7. excellent information is provided to you sir try t
View Tutorial By: Raghav at 2007-12-16 05:03:53
8. hi , sending of sms is failing. Please help me in
View Tutorial By: sudhakar at 2009-06-19 09:39:55
9. nice examlpe but u can make it more easy frnd
View Tutorial By: meghendra at 2009-02-14 00:21:31
10. how to display images in j2me?? thank you :)
View Tutorial By: bill at 2011-06-23 23:59:41