0% found this document useful (0 votes)
24 views12 pages

PHP Chapter 1

PHP-Chapter-1

Uploaded by

taj200153
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
24 views12 pages

PHP Chapter 1

PHP-Chapter-1

Uploaded by

taj200153
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 12

Web Applications

Development
ITSE 3302
‫تطوير تطبيقات الشبكة العالمية‬
Dr. Moamar Elyazgi
PHP
Introduction & Syntax Overview

Dr. Moamar Elyazgi


1.1 Introduction
• PHP is a server side scripting language that is used to develop Static websites or
Dynamic websites or Web applications.
• PHP stands for Hypertext Pre-processor, that earlier stood for Personal Home
Pages. PHP scripts can only be interpreted on a server that has PHP installed.
• PHP scripts can only be interpreted on a server that has PHP installed.
• A PHP file contains PHP tags and ends with the extension ".php".
• PHP code may be embedded into HTML code, or it can be used in combination
with various web template systems, web content management system and web
frameworks. 3
1.2 Common Uses of PHP
PHP performs system functions, i.e. from files on a system it can
create, open, read, write, and close them. The other uses of PHP are:
1. PHP can handle forms, i.e. gather data from files, save data to a file,
thru email you can send data, return data to the user.
2. You add, delete, modify elements within your database thru PHP.
3. Access cookies variables and set cookies.
4. Using PHP, you can restrict users to access some pages of your
website.
4
5. It can encrypt data.
1.3 Characteristics of PHP
• Five important characteristics make PHP's practical nature possible:

1 Simplicity

2 Efficiency
3 Security
4 Flexibility

5 Familiarity
5
1.4 Script in PHP
• To get a feel of PHP, first start with <html>
<head>
simple PHP scripts.
<title>Hello World</title>
• Since "Hello, World!" is an essential <body>
example, first we will create a <?php
friendly little "Hello, World!" script. echo "Hello, World!";
?>
• As mentioned earlier, PHP is </body>
embedded in HTML. That means </html>
that in amongst your normal HTML
(or XHTML if you're cutting-edge) It will produce the following result:
you'll have PHP statements like this: Hello, World! 6
1.4 Script in PHP
• A PHP file can also contain tags such as HTML and client side
scripts such as JavaScript.
• HTML is an added advantage when learning PHP Language.
You can even learn PHP without knowing HTML but it’s
recommended you at least know the basics of HTML.
• Database management systems DBMS for database powered
applications.
• For more advanced topics such as interactive applications and
web services, you will need JavaScript and XML.
7
1.5 Escaping to PHP
• Escape sequences are used for escaping a character during the string
parsing.
• It is also used for giving special meaning to represent line breaks, tabs,
alert and more.
• The escape sequences are interpolated into strings enclosed by double
quotations or heredoc syntax.
• If a string is within the single quotes or in nowdocs, then the escape
sequence will not work to get the expected result.
• Escape sequences are started with the escaping character backslash (\)
followed by the character which may be an alphanumeric or a special
character. 8
1.5 Escaping to PHP
• Widely used Escape Sequences in PHP
• In this section, I have listed some of the widely used escape sequences and
describe how they are used to escape the special character or to give meaning
by combining with some alphanumeric characters.

• \’ – To escape ‘ within single quoted string.


• \” – To escape “ within double quoted string.
• \\ – To escape the backslash.
• \$ – To escape $.
• \n – To add line breaks between string.
• \t – To add tab space.
• \r – For carriage return. 9
1.6 Commenting PHP Code
• A comment is the portion of a
program that exists only for <?php
the human reader and stripped # This is a comment, and
out before displaying the # This is the second line of the
programs result. There are two comment
commenting formats in PHP: // This is a comment too. Each
1. Single line comment used for style comments only
quick notes about complex print "An example with single
code or to temporarily disable line comments";
a line of PHP code. You need ?>
to add // or # before the code. 10
1.6 Commenting PHP Code

<?php

2. Multi-line comment used to /* This is a comment with multiline


Author : Mohammad Saed
comment out large blocks of
Purpose: Multiline Comments Demo
code or writing multiple line Subject: PHP
comments. You need to add /* */
before and */ after the code. print "An example with multi line
comments";
?>
11
12

You might also like