Introduction To Programming in PHP: Lecture 1 - Getting Started
Introduction To Programming in PHP: Lecture 1 - Getting Started
+ database
Forums/CMS/Wiki’s
Website calling without PHP
Websites calling with PHP
Agenda
?>
</body>
</html>
Scripts
<?php
// statements
?>
Code (declaration) Blocks
<?php
// comments
echo “Hello World!”;
print “Hello World!”;
?>
Comments
Line Comment
// This is a line comment.
# This is a line comment as well.
Block Comment
/* This is a block comment. It (mostly) consists of
multiple lines and has an opening and closing
comment sign. */
Scripts
<?php
// calling functions
phpinfo();
?>
Variables
! $nameVariable = value;
identifier
$age = 18;
echo “<p>My age is “ . $age . “.</p>”;
Constants
! define(“NAME_CONSTANT”, value);
identifier
define(“AGE”, 18);
echo “<p>My age is “ . AGE . “.</p>”;
Scripts
<?php
// calling functions
$round = 3.356;
echo round($round); parameter
// or
echo round(3.356); argument
?>
Scripts
<?php
// calling functions
$stomach = “”;
if(empty($stomach))
{
echo “Grumble, grumble!”;
}
?>
string
Case Sensitivity / Conventions
variables functions
constants keywords and constructs
(if, else, null, foreach, echo etc.)
Be consistent!
Result:
Clear code (no chaos!);
Less errors.
Questions?