Object Instance Working with Strings

 

Classes are nothing without objects.We can create multiple objects from a class. Each object has all the properties and methods defined in the class, but they will have different property values.

An object of a class is created using the new keyword.

Example: $bsc and $bzc is instances of the class Group:

<?php class Group

{

public $name;

function set_name($name)

{

    $this->name=$name;

}

function get_name;

{

    return $this->name;

}

}

$bsc=new Group();

$bzc=new Group();


$bsc->set_name('BSC');

$bzc->set_name('BZC');


echo $bsc->get_name(;

echo "<br>";

echo $bzc->get_name();

?>





Comments

Popular posts from this blog

PHP Array Functions

String Functions in C Language(C Language)