
PHP/MySQL / Code (page 9)
<!DOCTYPE html>
<html>
<body>
<?php
$arr1 = [110, 140, 170, 200, 230, 260];
foreach ($arr1 as $val){
echo "$val\n";
}
?>
</body>
</html>
<!DOCTYPE html>
<html>
<body>
<?php
$var = "Fond of Code";
echo "The variable \$var is of " . gettype($var) . " type" .PHP_EOL; $var = 1480;
echo "The variable \$var is of " . gettype($var) . " type" .PHP_EOL; $var = false;
echo "The variable \$var is of " . gettype($var) . " type" .PHP_EOL; $var = [10,20,30,40, 50];
echo "The variable \$var is of " . gettype($var) . " type" .PHP_EOL;
?>
</body>
</html>
<!DOCTYPE html>
<html>
<body>
<?php
class Cars {
public $name;
public $color;
public function __construct($name, $color) {
$this->name = $name;
$this->color = $color;
}
public function intro() {
echo "I'm a {$this->name} and my color is {$this->color}.";
}
}
class Strawberry extends Cars {
public function message() {
echo "Am I a car or a plane ? ";
}
}
$strawberry = new Strawberry("Pontiac", "blue");
$strawberry->message();
$strawberry->intro();
?>
</body>
</html>
<!DOCTYPE html>
<html>
<body>
<?php
interface Cars {
public function makeSound();
}
class Car implements Cars {
public function makeSound() {
echo "WWWrooommm";
}
}
$Cars = new Car();
$Cars->makeSound();
?>
</body>
</html>
<!DOCTYPE html>
<html>
<body>
<?php
class Car {
var $name;
var $color;
function __construct($name, $color) {
$this->name = $name;
$this->color = $color;
}
function __destruct() {
echo "The car is a {$this->name} and its color is {$this->color}.";
}
}
$apple = new Car("Pontiac", "red");
?>
</body>
</html>

Reproduce this code, choosing one of the compilers below (don't copy and paste! It would be too easy). They all have the same function, just choose one according to your preferences.
When copying your code, replace the existing (default) code already in the compiler with your own.
Warning ! Choose the compiler based on the formatting (e.g., with or without HTML tags). For some of these compilers, you must choose the programming language yourself from the menu that is then offered. Of course, don't forget to click on RUN !
Some of the external links presented below, are not under the direct responsibility of Fond of Code. We cannot therefore be held responsible for the quality/Viability, or the temporary nor permanent interruption of some of them.
» Creation date: 1994
* Created by Rasmus Lerdorf
* Developed by The PHP Group
* Influenced by C/C ++, Java and PERL
* Written in C
* Cross-platform
* Free license / PHP license
The comments you leave us are systematically subject to rigorous moderation. Incivility and slander, threats, intimidation of all kinds, more generally all gratuitous verbal violence, or the dissemination of unverified information... are not tolerated. We also reserve the right to publish only comments which effectively advance the debate and allow a better understanding of the subject covered by the article presented on this page (as well as all its ramifications) and this, whatever its overall content.
Fond of Code TM © ®
All rights reserved - Protected Trademark/Logo (INPI)
Legal structures based in
Nice - FRANCE
Montreal - Canada
By appointment
SIRET: 41138921600028 (France)
Inc. : 661515-5 (Canada, Qc.)
Official resumption in France : March 2025
Beta version of the website : May 2024
Implementation : July 2024
Launch of initial activity : 1996 (Europe and North America)
New version of the website : April 2025
Fond of Code official launch : May 2025