1<?php
2class Fruit {
3 public $name;
4 public $color;
5
6 function __construct($name, $color) {
7 $this->name = $name;
8 $this->color = $color;
9 }
10 function get_name() {
11 return $this->name;
12 }
13 function get_color() {
14 return $this->color;
15 }
16}
17
18$apple = new Fruit("Apple", "red");
19echo $apple->get_name();
20echo "<br>";
21echo $apple->get_color();
22?>
1var numbers = [10, 20, 30, 40] // sums to 100var sum = 0;for (var i = 0; i < numbers.length; i++) { sum += numbers[i]}