Skip to content

Instantly share code, notes, and snippets.

@pavanBS
Last active July 4, 2018 12:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pavanBS/08752eb69c7b7c41a5e496b6b616158b to your computer and use it in GitHub Desktop.
Save pavanBS/08752eb69c7b7c41a5e496b6b616158b to your computer and use it in GitHub Desktop.
<?php
class Mobile {
/* Member variables */
var $price;
var $title;
/* Member functions */
function setPrice($par){
$this->price = $par;
}
function getPrice(){
echo $this->price ."<br/>";
}
function setName($par){
$this->title = $par;
}
function getName(){
echo $this->title ." <br/>";
}
}
$Samsung = new Mobile();
$Xiaomi = new Mobile();
$Iphone = new Mobile();
$Samsung->setName( "SamsungS8 );
$Iphone->setName( "Iphone7s" );
$Xiaomi->setName( "MI4" );
$Samsung->setPrice( 90000 );
$Iphone->setPrice( 65000 );
$Xiaomi->setPrice( 15000 );
Now you call another member functions to get the values set by in above example
$Samsung->getName();
$Iphone->getName();
$Xiaomi->getName();
$Samsung->getPrice();
$Iphone->getPrice();
$Xiaomi->getPrice();
?>
@Mehedimuaz
Copy link

There would be a closing double quote (") after SamsungS8 on line 23.

$Samsung->setName( "SamsungS8 );

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment