0
Fill in the blanks to declare a class Student with a sayHi() method:
Student { public $name; public $age; public sayHi() { echo "Hi!"; } }
14 Réponses
+ 3
class
Student {
public $name;
public $age;
public function printData() {
echo
$this->name;
echo
$this
->age;
}
}
+ 1
function
+ 1
Class
Function
0
Fill in the blanks to declare a class Student and a method that prints its name and age properties.
Student {
public $name;
public $age;
public function printData() {
$this->name;
echo
->age;
}
answer would be : // class, //echo, //$this
understand this topic :
<!DOCTYPE html>
<html>
<body>
<?php
class Fruit {
// Properties
public $name;
public $color;
// Methods
function set_name($name) {
$this->name = $name;
}
function get_name() {
return $this->name;
}
}
$apple = new Fruit();
$banana = new Fruit();
$apple->set_name('Apple');
$banana->set_name('Banana');
echo $apple->get_name();
echo "<br>";
echo $banana->get_name();
$blue = new Fruit ();
$black = new Fruit ();
$blue->set_name ("Egg");
echo $blue->get_name();
echo "<br>";
?>
</body>
</html>
0
class
function
0
class
echo
$this
0
class
echo
$this
This is the ans
0
the answer
class
function
0
echo
0
answer would be : // class, //echo, //$this
0
Class
Function
0
class , echo and $this
- 1
class
Student {
public $name;
public $age;
public
function
sayHi() { echo "Hi!"; }
}
// class
//function
- 1
Answer:
static
self
::