Jul 26, 2024
htdocs
called website
.index.php
as the home page. Code structure:
<?php
echo "I like pizza";
?>
<?php ... ?>
echo "Your message";
//
for single line, /* ... */
for multi-line.!
+ tab in VS Code.$name = 'SpongeBob';
$
.+
, -
, *
, /
, %
(modulus).++
, Decrement: --
.$fruits = array("apple", "banana", "cherry");
$fruits[0]
returns "apple".$colors = array("red" => "#FF0000", "green" => "#00FF00");
function add($a, $b) {
return $a + $b;
}
include
to add code from external files. This promotes reusability:
include 'header.php';
include 'footer.php';
session_start()
to begin a session.mysqli_connect()
.try
and catch
blocks.$sql = "INSERT INTO users (username, password) VALUES ('$username', '$hash')";
mysqli_query()
to execute SQL queries.