special thanks to Jan Michelfeit & Martin Kruliš
Create a simple page using a CGI script in Python so that:
hello {user}
page is returned..php
files.
<?php … ?>
blocks interpreted and executed.
$
.
'a $b \n'
"a $b \n"
<?php … ?>
blocks can be arbitrarily interleaved with HTML
if (cond) stmt; elseif (cond2) stmt2; else ...
while (cond) stmt; do stmt; while (cond);
for (init; cond; inc) stmt;
foreach (array as [ $key => ] $value) stmt;
...
<!DOCTYPE html>
<body>
<?php
$user = $_GET['user'];
echo 'Hello ' . $user;
?>
</body>
index.php
pageVia " superglobal " arrays
$_GET
- URL query parameters$_POST
- form data from request body$_FILES
- records about uploaded files$_COOKIE
$_SERVER
- request details (e.g., headers)Create a simple page using PHP so that:
Hello {user}
page is shown.Download archive with initial HTML pages and use PHP to get rid of code duplication.
.php
files with header HTML code in a single file only and footer in a single file only.
require
to assemble the page back together.
loadCsv($filePath)
that loads a given CSV file into a two-dimensional associative array where:
[ // example of an output of the function
"978-0441172719" => [ "978-0441172719", "Dune", "Frank Herbert", "18.68" ],
"978-0316438988" => [ "978-0316438988", "Blood of Elves", "Andrzej Sapkowski", "12.79" ],
// ...
]
loadCsv($filePath)
function.