Business and Technology Consulting Organization in Mumbai
Home
About Us
ETG Consultancy
Management Team
Products
Jewellery Production Process Management System
HR Recruitment & Process Management Solution
Business Portal, Solutions for small business
Path to Achieve, Helping others is true fun!
Hospitality Service Solution
We also provide customised product solution as per your industry need. Please
let us know
if we can help any way!
Consultancy
Solutions
Web Designing
Asp.net, SQL
SEO & Article Service
Php, MySQL
WCF Development
IPhone, Android
Contact Us
Send Enquery
ETG on Facebook
ETG on LinkedIn
Career
About Us
Products
HR Product
Jewellery Product
Business Portal
Portfolio
Service
Contact Us
Whitepapers
Clients Feedback
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
Manufacturers In India
Manufacturer Importers Exporters in India & China
http://ebusinesszone.net/
Uk Marketplace
Hotels in london, properties in Uk
http://ebusinesszone.net/uk
Leave your comment.
Reduce your Dialy IT Cost, Consult with us
Stay healthy in recession
Advertisement
Sponsored by
©2009 ETG Consultancy, All Rights Reserved
Privacy Policy
|
Terms & Conditions
Asp.net, Ado.net, .Net Remoting, .Net Webservice, SQL, XML, XSLT, WCF, WPF, WWF NHibernate, Ajax, Jquery, DHTML