This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// DATA | |
$questions=[]; | |
$questions[] = [ | |
"q" => "1+2", | |
"ans" => "3" | |
]; | |
$questions[] = [ | |
"q" => "3x5", | |
"ans" => "15" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// DATA | |
$students = []; | |
$students[] = [ | |
"name" => "Thomas Mak", | |
"class" => "S1A", | |
"number" => 32, | |
"enrolled_classes" => [ | |
"Chinese", |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<title> | |
WebCode.run Editor | |
</title> | |
<style> | |
* { box-sizing: border-box; } | |
html, body { | |
margin: 0; | |
padding: 0; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
session_id("thomas23"); | |
session_start(); | |
// initialize the login name session variable. | |
$_SESSION["login_name"] = $_SESSION["login_name"] ?? ""; | |
// there is data POST from user. | |
if (count($_POST) > 0) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
session_id("thomas23"); | |
session_start(); | |
if (!isset($_SESSION["q_num"]) ){ | |
$_SESSION["q_num"] = 0; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$name = $_POST["name"] ?? ""; | |
$is_allowed = false; | |
if ($name == "Thomas") { | |
$is_allowed = true; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$className = "PHP Basic"; | |
$name = "Thomas"; | |
$day = date('l'); // Full weekday name, e.g. Sunday. | |
$dayNumber = date('w'); // 0-6 for Sun to Sat. | |
$isWeekend = false; | |
$isSunday = false; | |
if ($dayNumber == 6) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$score = 100; | |
$name = "Thomas"; | |
?> | |
<!DOCTYPE html> | |
<title>Sample PHP code</title> | |
<h1> | |
Hello <?php echo $name ?> | |
</h1> | |
<p> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$name = "PCMS PHP Class"; | |
$day = date("l"); | |
?> | |
<h1><?= $name ?></h1> | |
<p> | |
Welcome to the <?php echo $name ?>. | |
It is <?= $day ?> today. | |
</p> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$name = "Thomas"; | |
$day = date( "l"); | |
?> | |
<!DOCTYPE html> | |
<title>Hello PHP</title> | |
<h1>Hello <?= $name ?></h1> | |
<p> | |
It's <?= $day ?> today. |