.Net Framework, Asp.net, Ado.net, .Net Remoting, .Net Webservice, SQL, XML, XSLT, WCF, WPF, WWF NHibernate, Ajax, Jquery, DHTML
Ado.net
Asp.Net 2.0
SQL
C-Sharp
XML
Framework
IIS
XMLWebService
Architecture
UML
Project Management
SDLC
Methodologies
Design Patteren
OOP
WCF
.Net Remoting
WWF
MVP
MVC
Silver Light
N-Hibernate
Ajax
J-Query
SEO-Marketing
Site Map
Php
ETG Consultancy
Home
Consultancy
Portfolio
Join Us
Contact Us
Advertisement
Articles
WCF
User Control
Custom Control
Reflection
Deligate
UML
Globilisation
Threading
LINQ
Performance Tips
Interviews
OOPS in php programming
Object oriented php development.
Inhertance, Abstraction, Encapsulation, functiona overloading in php.
We have expert php mysql developer in mumbai india, We can provide
Php
JQuery
, php with mysql, php with ajax, php webservice, SEO compitable php design and more. Please
contact us to know more about our service
.
Also read
Basic php
|
Oops in php
|
Php custom object
|
Php API | Php Webservice
Php is a complete object oriented programming language. Now lets look how we can make object oriented php design
How to use/make class in php
Class design in php
<?php
1:
2:/**
3:Created by Arindam Chakraborty on 2nd Oct. 2009
4:
5:**/
6:
7:
8:class car {
9:
10: // explicitly adding class properties are optional - but is good practice
11: var $name;
12:
13: function __construct($car_name) {
14:
15: $this->name = $car_name;
16: }
17:
18:
19: public function get_name() {
20:
21: return $this->name;
22:
23: }
24:
25:
26: protected function set_name($new_name) {
27:
28: if (name != "Honda Civic") {
29: $this->name = strtoupper($new_name);
30: }
31:
32: }
33:
34:
35:}
36:
37:// 'extends' is the keyword that enables inheritance
38:class honda extends car {
39:
40:
41: protected function set_name($new_name) {
42:
43: if ($new_name == "Honda City") {
44: $this->name = $new_name;
45: }
46: else if($new_name == "Honda Civic") {
47: parent::set_name($new_name);
48: }
49:
50: }
51:
52: function __construct($car_name) {
53:
54: $this->set_name($car_name);
55: }
56:
57:
58:
59:}
60:
61:
62:
63:?>
64:
How to make inheritance in php
Inheritance in php
class car {
1:
2:}
3:
4:class maruti extends car {
5:
6:}
7:
8:So here 'extends' is the keyword that enables inheritance in php.
9:
How to make a new class object in php ?
How to create new object in php
1:// i am a creating a new car object
2:$objCar = new car("Stefan Mischook");
3:
4:// calling a function of that $objCar
5:echo "Calling a function" . $stefan->get_name();
6:
Abstract class in php
Abstract class in php
<?php
1:abstract class AbstractClass
2:{
3: // Force Extending class to define this method
4: abstract protected function getValue();
5: abstract protected function prefixValue($prefix);
6:
7: // Common method
8: public function printOut() {
9: print $this->getValue() . "\n";
10: }
11:}
12:
13:class ConcreteClass1 extends AbstractClass
14:{
15: protected function getValue() {
16: return "ConcreteClass1";
17: }
18:
19: public function prefixValue($prefix) {
20: return "{$prefix}ConcreteClass1";
21: }
22:}
23:
24:class ConcreteClass2 extends AbstractClass
25:{
26: public function getValue() {
27: return "ConcreteClass2";
28: }
29:
30: public function prefixValue($prefix) {
31: return "{$prefix}ConcreteClass2";
32: }
33:}
34:
35:$class1 = new ConcreteClass1;
36:$class1->printOut();
37:echo $class1->prefixValue('FOO_') ."\n";
38:
39:$class2 = new ConcreteClass2;
40:$class2->printOut();
41:echo $class2->prefixValue('FOO_') ."\n";
42:?>
43:
Advertisement
Asp.net Ajax SQL Developer
Contract base | Hour base | Module base
http://etgconsultancy.com
Web designer in Mumbai
Dhtml, Ajax, Jquery
http://etgconsultancy.com
SEO Consultant in Mumbai
Search Engine Optimization
http://etgconsultancy.com
PHP MySQL Developer
Contract base | Hour base | Module base
http://etgconsultancy.com
Manufacturers In India
Manufacturer Importers Exporters in India & China
http://e-tigers.net
Uk Marketplace
Hotels in london, properties in Uk
http://e-tigers.net/uk
Leave your comment.
Name
Email
Comments
Tell Us
8959+5
=
Reduce your Dialy IT Cost, Consult with us
Stay healthy in recession
Advertisement
Sponsored by
Professional Web developer in mumbai, Asp.net Ajax SQL
.Net developer in mumbai
Privacy Policy
©2009 ETG Consultancy, All Rights Reserved
Terms & Conditions
Asp.net, Ado.net, .Net Remoting, .Net Webservice, SQL, XML, XSLT, WCF, WPF, WWF NHibernate, Ajax, Jquery, DHTML