Professional Documents
Culture Documents
Disadvantages
It makes control of design and layout difficult
It doesn’t scale up to large number of pages
It is not very interactive
It can’t cope with rapidly changing content or presentation
Client-side scripts
Tools/Languages Use
Server-side scripts
Normally invisible to the user
Is mostly all about connecting websites to the back-end
servers
Creates 2-way communication
Client to server
Server to client
…cont’d…
7
print $some_var;
Or variables can be printed within double quotation
marks:
print "Hello, $name";
You cannot print variables within single quotation
marks:
print 'Hello, $name'; // Won't work!
Example(code)
22
Shows the
usage
of variables
Example (Output)
23
…cont’d…
24
Manipulate Strings
25
Concatenating strings
is like addition for strings, whereby characters are added to
the end of the string.
It is performed using the concatenation operator, which is
the period (.):
Examples
$city= 'Seattle';
$state = 'Washington';
$address = $city . $state;
String functions
Name Java Equivalent
strlen length
strpos indexOf
substr substring
strtolower, strtoupper toLowerCase, toUpperCase
trim trim
explode, implode split, join
strcmp compareTo
String Functions Example
29
…cont’d…
30
$age = 16;
print "You are " . $age . " years old.\n";
print "You are $age years old.\n"; # You are 16 years old.
PHP
Examples
$n = 3.14;
$n = round ($n); // 3
It can also round to a specified number of decimal places:
$n = 3.142857;
$n = round ($n, 3); // 3.143
$n = 20943;
$n = number_format ($n); // 20,943
This function can also set a specified number of decimal points:
$n = 20943;
$n = number_format ($n, 2); //
20,943.00
Example(code)
35
Example(output)
36
Work with constants
37