We have upgraded our system to latest version of MyBB. We are very sorry for the downtime ! Read More.
Advertise Here | Remove Ads

Class syntax of PHP
  • 0 Vote(s) - 0 Average

PHP Class syntax of PHP
PHP is an Object Oriented Programming language. We can also work in procedural way with PHP but I think OO way is the best way Thumbs Up

Because PHP support OO we can use Class and objects in PHP. So lets check out the syntax of PHP Class Smile

Syntax :
PHP Code:
class ClassName{
//property and methods here

Simple Class Example

PHP Code:
class simpleClass {
//property declaration. similar like a variable
public $variable 100
//method declation, similar like a function
public function display(){
ehcho $this->variable// we can use $this-> operator to access class property


$obj = new simpleClass// make an object of a class with new keyword
$obj->display(); // this is how we can access a method of a class by using its object


[Image: FCgKq6Jl.png]

Forum Jump:

Users browsing this thread:
1 Guest(s)

Advertise Here | Remove Ads