Docsity
Docsity

Prepare for your exams
Prepare for your exams

Study with the several resources on Docsity


Earn points to download
Earn points to download

Earn points by helping other students or get them with a premium plan


Guidelines and tips
Guidelines and tips

Php, Lecture notes of Computer Engineering and Programming

php - php

Typology: Lecture notes

2015/2016

Uploaded on 10/20/2016

.23368
.23368 🇮🇳

4

(1)

2 documents

1 / 64

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Ceuturion University of Technology and Management
Shivani Nanda
Web Technology
1
LAMPP Installation
on Ubuntu
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16
pf17
pf18
pf19
pf1a
pf1b
pf1c
pf1d
pf1e
pf1f
pf20
pf21
pf22
pf23
pf24
pf25
pf26
pf27
pf28
pf29
pf2a
pf2b
pf2c
pf2d
pf2e
pf2f
pf30
pf31
pf32
pf33
pf34
pf35
pf36
pf37
pf38
pf39
pf3a
pf3b
pf3c
pf3d
pf3e
pf3f
pf40

Partial preview of the text

Download Php and more Lecture notes Computer Engineering and Programming in PDF only on Docsity!

Ceuturion University of Technology and Management

1

LAMPP Installation

on Ubuntu

Ceuturion University of Technology and Management

2

LAMPP Installation on Ubuntu

http://howtoubuntu.org/how-to-install-lamp-on-

ubuntu

https://www.digitalocean.com/community/tutoria

ls/how-to-install-linux-apache-mysql-php-lamp-

stack-on-ubuntu

Sublime Editor for LINUX platform

http://monkeyhacks.com/post/how-to-install-

sublime-text-2-on-ubuntu-14-

Ceuturion University of Technology and Management

4

Escaping to PHP

  • The PHP parsing engine needs a way to differentiate

PHP code from other elements in the page.

  • The mechanism for doing so is known as ‘ escaping to

PHP ’.

  • All PHP statements end with a semi-colon
  • Each PHP script must be enclosed in the reserved PHP

tag

<?php

// PHP code goes here

?>

Ceuturion University of Technology and Management

5

A PHP script can be placed

anywhere in the document

A PHP script starts with

The default file extension

for PHP files is “.php”

A PHP file normally

contains HTML tags , and

some PHP scripting code

PHP Syntax Overview

Ceuturion University of Technology and Management

7

Commenting PHP Code

  • Multi-lines comments: They are generally used to provide

pseudocode algorithms and more detailed explanations when

necessary. The multiline style of commenting is the same as in C

<? / This is a multiline comment*

Author : Shivani Nanda

Purpose: Multiline Comments Demo

Subject: PHP

Ceuturion University of Technology and Management

8

PHP is Whitespace insensitive

  • PHP whitespace insensitive means that it almost never matters

how many whitespace characters you have in a row i.e. one

whitespace character is the same as many such characters

<?

$four = 2 + 2; // single spaces

$four =<tab2+2 ; // spaces and tabs

$four =

2+

2; // multiple lines

?>

Ceuturion University of Technology and Management

10

PHP : Case Sensitive for Variables

PHP variables must begin with a “$” sign

Case-sensitive ($Foo != $foo != $fOo)

Certain variable names reserved by PHP

Form variables ($_POST, $_GET)

Server variables ($_SERVER)

Etc.

Ceuturion University of Technology and Management

11

$greeting = "Welcome to PHP!";

Statements are expressions terminated by ;

  • A statement in PHP is any expression that is followed by a semicolon (;)
  • Any sequence of valid PHP statements that is enclosed by the PHP tags is

a valid PHP program

  • The above line represents a typical statement in PHP, which in this case

assigns a string of characters to a variable called $greeting

Ceuturion University of Technology and Management

13

Braces make Blocks

  • Although statements cannot be combined like

expressions, we can always put a sequence

of statements anywhere a statement can go by enclosing

them in a set of curly braces

Here both statements are equivalent

if (3 = = 2 + 1)

print(“Good - I haven‘t totally lost my mind ”);

if (3 = = 2 + 1)

{ print(“Good - I haven’t totally”);

print(“lost my mind.
”); }

Ceuturion University of Technology and Management

14

PHP : Variable Types

  • All variables in PHP are denoted with a leading

dollar sign ($)

  • The value of a variable is the value of its most

recent assignment

  • Variables are assigned with the = operator, with the

variable on the left-hand side and the expression to

be evaluated on the right

  • Variables can, but do not need, to be declared before

assignment

Ceuturion University of Technology and Management

16

PHP : Data Types for Variables

  • PHP has a total of eight data types which we use to construct

our variables:

  • Integers: are whole numbers, without a decimal point, like

4195

  • Doubles: are floating-point numbers, like 3.14159 or 49.
  • Booleans: have only two possible values either true or false
  • NULL: is a special type that only has one value: NULL

Ceuturion University of Technology and Management

17

PHP : Data Types for Variables

  • Strings: are sequences of characters, like 'PHP supports

string operations.’

  • Arrays: are named and indexed collections of other

values

  • Objects: are instances of programmer-defined classes,

which can package up both other kinds of values and

functions that are specific to the class

  • Resources: are special variables that hold references to

resources external to PHP (such as database connections)

Ceuturion University of Technology and Management

19

They are whole numbers, without a decimal

point,

like 4195

They are the simplest type

They correspond to simple whole numbers, both

positive and negative

Integer

$int_var = 12345;

// Integers can be assigned to variables

$another_int = -12345 + 12345;

// or used in expressions

Ceuturion University of Technology and Management

20

Boolean

  • They have only two possible values either true or false
  • PHP provides a couple of constants especially for use as

Booleans: TRUE and FALSE

if (TRUE)

print(“This will always print
”);

else

print(“This will never print
”);