Show sourcecode
The following files exists in this folder. Click to view.
webbserverprogrammering/exercises/classes/
ovn_cls1.php
ovn_cls2.php
ovn_cls3.php
ovn_cls4.php
ovn_cls5.php
ovn_cls6.php
ovn_cls7.php
ovn_cls3.php
34 lines ASCII Windows (CRLF)
<?php
class Ball
{
// Properties
private $color;
private $radius;
// Methods
function set_ball($color, $radius)
{
$this->color = $color;
$this->radius = $radius;
}
function get_ball()
{
return [$this->color, $this->radius];
}
}
$ball1 = new Ball();
$ball1->set_ball("red", "12");
$ball2 = new Ball();
$ball2->set_ball("blue", "12");
$ball3 = new Ball();
$ball3->set_ball("green", "12");
$balls = [$ball1->get_ball(), $ball2->get_ball(), $ball3->get_ball()];
print_r($balls);