CH 08 Introduction To Server-Side Development With PHP
CH 08 Introduction To Server-Side Development With PHP
Side Development
with PHP
Chapter 8
5 Functions
7
Randy Connolly and Ricardo Hoar Fundamentals of Web Development
Section 1 of 5
WHAT IS SERVER-SIDE
DEVELOPMENT
Randy Connolly and Ricardo Hoar Fundamentals of Web Development
What is Server-Side
Development
The basic hosting of your files is achieved through a
web server.
Server-side development is much more than web
hosting: it involves the use of a programming
technology like PHP or ASP.NET to create scripts that
dynamically generate content
Consider distinction between client side and server
side…
<?php
# single-line comment
/*
This is a multiline comment.
They are a good way to document functions or
complicated blocks of code
*/
$artist = readDatabase(); // end-of-line comment
?>
$count = 42;
String Letters
$firstName = "Pablo";
$lastName = "Picasso";
/*
Example one:
The first four lines are equivalent. Notice that you can reference PHP variables within a string literal
defined with double quotes.
The resulting output for the first four lines is: <em>Pablo Picasso</em>
The last one displays: <em> $firstName $lastName </em>
*/
/*
Example two:
These two lines are also equivalent. Notice that you
can use either the single quote symbol or double quote
symbol for string literals.
*/
echo "<h1>";
echo '<h1>';
/*
Example three:
These two lines are also equivalent. In the second
example, the escape character (the backslash) is used
to embed a double quote within a string literal defined
within double quotes.
*/
echo '<img src="23.jpg" >';
echo "<img src=\"23.jpg\" >";
Sequence Description
\n Line feed
\t Horizontal tab
\\ Backslash
\$ Dollar sign
\" Double quote
echo "<img src='23.jpg' alt='". $firstName . " ". $lastName . "' >";
echo "<img src='$id.jpg' alt='$firstName $lastName' >";
echo "<img src=\"$id.jpg\" alt=\"$firstName $lastName\" >";
echo '<img src="' . $id. '.jpg" alt="' . $firstName . ' ' . $lastName . '" >';
echo '<a href="artist.php?id=' .$id .'">' .$firstName .' ' . $lastName .'</a>';
echo "<img src='23.jpg' alt='". $firstName . " ". $lastName . "' >";
echo "<img src='$id.jpg' alt='$firstName $lastName' >";
echo "<img src=\"$id.jpg\" alt=\"$firstName $lastName\" >";
echo '<img src="' . $id. '.jpg" alt="' . $firstName . ' ' . $lastName . '" >';
echo '<a href="artist.php?id=' .$id .'">' .$firstName .' ' . $lastName .'</a>';
PROGRAM CONTROL
Randy Connolly and Ricardo Hoar Fundamentals of Web Development
If…else
FUNCTIONS
Randy Connolly and Ricardo Hoar Fundamentals of Web Development
Functions
You mean we don’t write everything in main?
5 Functions
7
Randy Connolly and Ricardo Hoar Fundamentals of Web Development