Aug 8, 2024
C:\PHP).php -v.php -S localhost:4000..php extension.<?php ... ?> tags.<?php
echo "Hello, world!";
?>
<form action="site.php" method="get">
<input type="text" name="username"/>
<input type="submit" value="Submit"/>
</form>
$_GET['username'].$age = 25;
$name = "Mike";
$friends = array("Jim", "Pam", "Oscar");
$friends[0];count($friends);$grades = array(
"Jim" => "A+",
"Pam" => "B-",
);
$grades['Jim'];function sayHi($name) {
return "Hello $name!";
}
if ($isMale) {
echo "You are male";
} else {
echo "You are not male";
}
switch ($grade) {
case "A":
echo "You did amazing";
break;
default:
echo "Invalid grade";
}
for ($i = 1; $i <= 5; $i++) {
echo $i;
}
include to incorporate code from other files.include "header.php";
class Book {
public $title;
public $author;
}
function __construct($title, $author) {
$this->title = $title;
$this->author = $author;
}
```__
function getTitle() {
return $this->title;
}
function setTitle($title) {
$this->title = $title;
}
class ItalianChef extends Chef {
function makePasta() {
echo "Making pasta";
}
}