Chapter 1 IP
Chapter 1 IP
Chapter 1 IP
Abaleta 1
CHAPTER 1
The Server Side Scripting Basics
erver-side scripting
is a web server technology in which a user's request
is fulfilled by running a script directly on the web
server to generate dynamic web pages.
2. Access rights
About security:
Server-side scripts are never visible to the
browser as these scripts are executes on
the server and emit HTML corresponding
to user's input to the page.
Example:
<html> Output:
<head><title>PHP says hello</title></head>
<body>
<b>
<?php
print "Hello, World!";
?>
</b>
</body>
</html>
5 <html>
<head>
<title>Hello World</title>
</head>
<body>
<?php
echo ("Hello world!<br />");
print ('Goodbye.<br />');
print 'Over and out.';
?>
</body> Output:
</html>
Hello world!
Goodbye.
Over and out.
Output #1 Output #2
/* This is how to do a
multi-line comment and could be used comment out a block
of code */
?>
</body>
</html>
$variable_name = value;
•Variables in PHP are case sensitive. This means that $variable_name and $Variable_Name
are different.
•Variables with more than one word should be separated with underscores; for
example, $test_variable.
•Always end with a semicolon (;) to complete the assignment of the variable.
Output: 30
<?php
$my_string = "Jay is Handsome!";
echo " Jay is Handsome!";
?>
<?php
$my_string = "Jay is Handsome!";
echo “Time for Saying $my_string";
?>
<?php
$name1 = "Bill";
$name2 = "BILL";
$result = strcasecmp($name1, $name2);
if (!$result)
{
echo "They match.";
}
?>
Output:
Hello Jay. My name is: Paula
Hi, I'm Jay. Who are you? Hello Jay. My name is:
Hi, I'm Jay. Who are you? Hello Jay. My name is: Paula
+ Addition 2+2 4
- Subtraction 2-1 1
* Multiplication 2*2 4
/ Division 2/2 1
% Modulo (remainder)
Example: Increment
<?php
$counter=9;
$counter++;
echo "$counter";
?>
Example: decrement
<?php
$counter=9;
$counter--;
echo "$counter";
?>
17
- You can define constants in your program. A constant, like its
name implies, cannot change its value during the execution of your
program.
- It's defined using the define function, which takes the name of the
constant as the first parameter and the values as the second parameter
<?php
18
define("HELLO", "Hello world!");
echo HELLO; // outputs "Hello world."
?>
Sample Output:
Hello world!