CH 1
CH 1
Browser dependency
The browser or scripting host must support the scripting
language and capabilities.
Cannot connect to a back-end server, such as a data base or
file handling systems.
Scripts are restricted from arbitrarily accessing the local
hardware and file system for security reasons.
More development time and effort might be required
Client-side scripts can be viewed by the client using the
browser’s source-viewing capability, so sensitive information
such as passwords or other personally identifiable data
should not be on the client.
Examples of client side scripting
How most of the dynamic Web applications will work both MySQL and php
Basic Syntax
Most Web servers use .html for standard HTML pages and .php for
PHP files.
A PHP file normally contains HTML tags, just like an HTML file,
and some PHP scripting code.
Example
<?php
Echo“ This is php”;
?>
Each code line in PHP must end with a semicolon.
The semicolon is a separator and is used to distinguish
one set of instructions from another.
PHP Comments
Example
<?php
echo "This is the code for comment clarification<br>";
//echo"this is this first type of single line comment";
#this is the second type of single line comment
// multiple line comment start here
/*
you can write any clarification about your code here
*/
echo“Those are a type of comments in php";
?>
Sending Data to the Web Browser
To build dynamic Web sites with PHP, the first step is knowing how
to send data to the Web browser.
PHP has a number of built-in functions for this purpose.
The most common being echo and print.
Example:
echo 'Hello, world!';
echo "What's new?";
Example:
<html>
<body>
<?php
echo "Hello World";
?>
</body>
</html>
Working with Variables
Example:
<?php
$txt1="Hello World";
$txt2="1234";
echo $txt1 . " " . $txt2 ;
?>
The output of the script above will be: "Hello World
1234".
Manipulating Strings
$upperCase = strtoupper($originalString);
// outputs
Old string - String Capitalization 1234
New String - STRING CAPITALIZATION 1234
Manipulating Numbers