From eed2a056149f1168bf15a006b994c62cf1a112ee Mon Sep 17 00:00:00 2001 From: Raghav <raghavsmart1213@gmail.com> Date: Mon, 3 Mar 2025 07:05:56 +0000 Subject: [PATCH] Method calling using keyword --- _includes/Mic.class.php | 6 ++++++ test.php | 3 +++ 2 files changed, 9 insertions(+) diff --git a/_includes/Mic.class.php b/_includes/Mic.class.php index 4b82610..20a968c 100644 --- a/_includes/Mic.class.php +++ b/_includes/Mic.class.php @@ -8,4 +8,10 @@ class Mic public $model; public $light; public $price; + + // Creating methods.. + public function setLight($light){ + print($light); + print($this -> light); + } } diff --git a/test.php b/test.php index b3ed80d..f8c866c 100644 --- a/test.php +++ b/test.php @@ -27,6 +27,9 @@ $mic1->brand = "Toyota"; $mic2 -> brand = "Hyundai"; + $mic1 -> light = "RGB"; + $mic1 -> setLight("yellow"); + printf("mic1 = %s\n", $mic1 -> brand); printf("mic2 = %s", $mic2 -> brand); -- GitLab