-
-
Save pavanBS/08752eb69c7b7c41a5e496b6b616158b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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(); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
There would be a closing double quote (") after SamsungS8 on line 23.