How to start with oops php
It is most Important to learn OOPs PHP
1. For Advanced PHP we need to create two files 1st in index file and second is class file here it is
(a) index.php
(b) class_lib.php
2. After creating These two files we create a class in a file
<?php
class person {
}
?>
3. Add variable to your class this is also called add data to your class .One of the big difference
<?php
class person {
var $name;
}
?>
4. Add function method to your class And do not forget that in a class ,variable and properties
are same
<?php
class person {
var $name;
function set_name($new_name) {
$this->name = $new_name;
}
function get_name() {
return $this->name;
}
}
?>
It is most Important to learn OOPs PHP
1. For Advanced PHP we need to create two files 1st in index file and second is class file here it is
(a) index.php
(b) class_lib.php
2. After creating These two files we create a class in a file
<?php
class person {
}
?>
3. Add variable to your class this is also called add data to your class .One of the big difference
<?php
class person {
var $name;
}
?>
4. Add function method to your class And do not forget that in a class ,variable and properties
are same
<?php
class person {
var $name;
function set_name($new_name) {
$this->name = $new_name;
}
function get_name() {
return $this->name;
}
}
?>
No comments:
Post a Comment