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

Unit 1 Web Computing

Uploaded by

Tejaswini Pawar
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 views22 pages

Unit 1 Web Computing

Uploaded by

Tejaswini Pawar
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/ 22

What is HTTP

o HTTP stands for Hypertext Transfer Protocol.

o Hypertext Transfer Protocol is a set of rule which is used for transferring the
files like, audio, video, graphic image, text and other multimedia files on the
WWW (World Wide Web).

o HTTP is an application-level protocol. The communication usually takes place


through TCP/IP sockets, but any reliable transport can also be used.

o The standard (default) port for HTTP connection is 80, but other port can also
be used.

o The first version of HTTP was HTTP/0.9, which was introduced in 1991.

o The latest version of HTTP is HTTP/3, which was published in September 2019.
It is an alternative to its processor HTTP/2.

o This latest version is already in use on the web with the help of UDP (User
Datagram Protocol) instead of TCP (Transmission Control Protocol) for the
underlying transport protocol.

o HTTP is used to make communication between a variety of hosts and clients.


It supports a mixture of network configuration.

o HTTP is a protocol that is used to transfer the hypertext from the client end to
the server end, but HTTP does not have any security.

o Whenever a user opens their Web Browser, that means the user indirectly uses
HTTP.

Three important things about HTTP


Connectionless: HTTP is connectionless. When the HTTP client opens the
browser, the browser initiates an HTTP request. After making the request, the
client disconnect from the server and wait for the response. When the
response is ready, the server re-establish the connection again and delivers
the response to the client, after which the client disconnects the connection.
So both client and server know about each other during the current request
and response only.
Media Independent: HTTP is media independent. HTTP can deliver any sort of
data, as long as the two computers can read it.

Stateless: The HTTP is stateless. The client and server just know about each other
just during the current request. If the connection is closed, and two computers
want to connect again, they need to provide information to each other anew, and
the connection is handled as the very first one.

HTTP Needs
o The HTTP was designed mainly to fetch the html document and send it to the
client. That all the HTTP was doing in 1991, and it did not support other media
types, it just delivers html document.

o It was designed in an exquisite way, and it was continually evolved, and


features were being added to it, it becomes the most convenient way to quickly
and reliably move data on the web.

Prerequisite
Before learning HTTP, you must have the basic knowledge of web concepts,
web browsers, web servers, client and server architecture based software.

Audience
Our HTTP tutorial is designed to help beginners and professionals both.

Problems
We assure you that you will not find any difficulty while learning HTTP tutorial.
But, if you find any type of mistake, then you can post it in our comment
section.

Parameters of HTTP
In this section, we will discuss various HTTP parameters and their syntax. For
example, date and time format, character set, etc. These parameters are used
in the construction of our request and response message while writing the
HTTP program of the client or server.

The various parameters of HTTP are as follows:


HTTP Version
To indicate the version of the protocol, HTTP uses
a <major>.<minor> numbering scheme. The protocol versioning policy allows
the sender to indicate the format of a message and its capacity for
understanding further HTTP communication.

The first line in the HTTP-Version field indicates the version of the HTTP
message.

Syntax

1. HTTP-Version = "HTTP" "/" 1*DIGIT "." 1*DIGIT

Entity Tags
Entity tags are used to compare two or more entities from the same requested
resource.

Syntax

1. entity-tag = [ weak ] opaque-tag

2. weak = "W/"

3. opaque-tag = quoted-string
4. An Entity tag must be unique across all the entity versions associated
with a particular resource.
Web Browser and Web Server.
The terms web browser and web server are very common in the field of
computer science and Internet, however people often get confused
between the two. The most basic difference between a web browser and a
web server is that a web browser is an application software which is used
to browse and display webpages available over the Internet, whereas
a web server is a software hosted on a dedicated computer which provides
these documents when requested by web browsers.
What is a Web Browser?

A web browser is an application software that can process and display a web page
on the internet. The web browser is capable to make a request for web services
and documents to web server. It acts an interface between the server and the
client. As web browser is a software, thus it is to be installed on the client
computer and used to surf the internet for websites and web pages. Popular
examples of web browsers include Google Chrome, Microsoft Internet Explorer,
Microsoft Edge, Mozilla Firefox, Opera Mini, etc.

What is a Web Server?

A web server is a dedicated computer that sends web based documents to the
client’s computer when request through the web browser. A web server accepts
HTTP request from the client’s browser, processes it to find the required
document, and then sends a suitable response to client machine.

A web server is a basically a set of hardware and software whose primary function
is to serve web-based material through the internet on demand.

What is PHP
PHP is an open-source, interpreted, and object-oriented scripting language
that can be executed at the server-side. PHP is well suited for web
development. Therefore, it is used to develop web applications (an application
that executes on the server and generates the dynamic page.).

PHP was created by Rasmus Lerdorf in 1994 but appeared in the market in
1995. PHP 7.4.0 is the latest version of PHP, which was released on 28
November. Some important points need to be noticed about PHP are as
followed:
o PHP stands for Hypertext Preprocessor.

o PHP is an interpreted language, i.e., there is no need for compilation.

o PHP is faster than other scripting languages, for example, ASP and JSP.

o PHP is a server-side scripting language, which is used to manage the dynamic


content of the website.

o PHP can be embedded into HTML.

o PHP is an object-oriented language.

o PHP is an open-source scripting language.

o PHP is simple and easy to learn language.

Why use PHP


PHP is a server-side scripting language, which is used to design the dynamic
web applications with MySQL database.

o It handles dynamic content, database as well as session tracking for the


website.

o You can create sessions in PHP.

o It can access cookies variable and also set cookies.

o It helps to encrypt the data and apply validation.

o PHP supports several protocols such as HTTP, POP3, SNMP, LDAP, IMAP, and
many more.

o Using PHP language, you can control the user to access some pages of your
website.

o As PHP is easy to install and set up, this is the main reason why PHP is the
best language to learn.

o PHP can handle the forms, such as - collect the data from users using forms,
save it into the database, and return useful information to the user. For
example - Registration form.
PHP Features
PHP is very popular language because of its simplicity and open source. There are
some important features of PHP given below:

Performance:

PHP script is executed much faster than those scripts which are written in
other languages such as JSP and ASP. PHP uses its own memory, so the server
workload and loading time is automatically reduced, which results in faster
processing speed and better performance.

Open Source:

PHP source code and software are freely available on the web. You can develop
all the versions of PHP according to your requirement without paying any cost.
All its components are free to download and use.

Familiarity with syntax:

PHP has easily understandable syntax. Programmers are comfortable coding


with it.

Embedded:

PHP code can be easily embedded within HTML tags and script.

Platform Independent:
PHP is available for WINDOWS, MAC, LINUX & UNIX operating system. A PHP
application developed in one OS can be easily executed in other OS also.

Database Support:

PHP supports all the leading databases such as MySQL, SQLite, ODBC, etc.

Error Reporting -

PHP has predefined error reporting constants to generate an error notice or


warning at runtime. E.g., E_ERROR, E_WARNING, E_STRICT, E_PARSE.

Loosely Typed Language:

PHP allows us to use a variable without declaring its datatype. It will be taken
automatically at the time of execution based on the type of data it contains
on its value.

Web servers Support:

PHP is compatible with almost all local servers used today like Apache,
Netscape, Microsoft IIS, etc.

Security:

PHP is a secure language to develop the website. It consists of multiple layers


of security to prevent threads and malicious attacks.

Control:

Different programming languages require long script or code, whereas PHP


can do the same work in a few lines of code. It has maximum control over the
websites like you can make changes easily whenever you want.

A Helpful PHP Community:

It has a large community of developers who regularly updates documentation,


tutorials, online help, and FAQs. Learning PHP from the communities is one of the
significant benefits.
Lexical Structure
The lexical structure of a programming language is the set of basic rules that
governs how you write programs in that language. It is the lowest-level
syntax of the language and specifies such things as what variable names look
like, what characters are used for comments, and how program statements are
separated from each other.

White Space
White space can contain the characters for tabs, blanks, newlines, and form
feeds. These characters are ignored except when they serve to separate other
tokens. However, blanks and tabs are significant in strings.

Comments
There are two types to represent the comments, such as:

1. Single line comments begin with the token // and end with a carriage return.
For example, //this is the single-line syntax.

2. Multi-Line comments begin with the token /* and end with the token */
For example, /* this is multiline syntax*

What is a variable?

In programming, a variable is a value that can change, depending on conditions or on


information passed to the program. Typically, a program consists of instruction s that
tell the computer what to do and data that the program uses when it is running. The
data consists of constants or fixed values that never change and variable values
(which are usually initialized to "0" or some default value because the actual values
will be supplied by a program's user). Usually, both constants and variables are
defined as certain data type s. Each data type prescribes and limits the form of the
data. Examples of data types include: an integer expressed as a decimal number, or
a string of text characters, usually limited in length.
In object-oriented programming , each object contains the data variables of
the class it is an instance of. The object's method s are designed to handle the actual
values that are supplied to the object when the object is being used.

Reference Variables
A reference variable is a variable that points to an object of a given class,
letting you access the value of an object. An object is a compound data
structure that holds values that you can manipulate. A reference variable does
not store its own values. Instead, when you reference the reference variable,
OpenROAD uses the values in the corresponding object. The object is made
up of attributes, which can be simple variables, reference variables, or array
variables.
The class of an object defines its attributes. OpenROAD includes both system
classes and user-defined classes.
In your 4GL code, when you reference a reference variable, you can work with
the entire object as a single unit. For example, you can retrieve a row from a
database table and assign all values from the row to a single object and then
pass the object to a called procedure.

How You Can Declare Reference Variables


To declare a reference variable, use the following syntax:
name = class [ [with] default null]

The value of class can be any named user class or system class (for a
complete list of system classes, see the Language Reference Guide online
help). The following example declares a reference variable of the StringObject
class:
strobj = StringObject;

All reference variables are nullable.


When you create a field on a form, you specify the variable's name and data
type on the field's property inspector in the OpenROAD Workbench. Unless
you specify otherwise, OpenROAD automatically declares the variable that
you use to access the data in that field. If the field is a named composite field,
such as a stackfield or subform, the variable is a reference variable and you
may or may not define its data type (class).
If you do define the data type for the reference variable, the data type must be
a system or user class name. You can choose to exclude fields for some of
the attributes (this provides a way to keep additional undisplayed control
information).
If you do not name the class when you create a composite field, OpenROAD
creates an unnamed class that you can reference only within the frame that
contains the composite field.

How You Can Use Reference Variables


In OpenROAD, you can work with an object as a whole or with the attributes
of the object. To manipulate the object as a single unit, use the name of the
object's reference variable in your 4GL code.
For example, you can create a subform and specify its variable's class as a
named user class. In your program you could then pass the values in the
subform fields to a procedure simply by naming the variable as a procedure
parameter.
In the following statement, customer is the name of the variable associated
with a subform:
callproc update_cust (new = customer)

To access an individual attribute that belongs to an object, use the dot


notation:
referencevariable_name.attribute_name

For example, assume that the subform previously described contained a field
called Address. To reference that field, you would use:
customer.Address

In the following example, City and Street are attributes of class addr, and
address is a declared reference variable:
address.City = 'Dallas';
x = address.Street;
callframe delete_old (address = address.City);
OpenROAD checks references to attributes by name and produces compiler
errors if the variable's class does not contain those attributes. For example,
given the following declarations:
a = Addr;
b = Addr;
tmp_char = varchar(30) not null;

Some valid references would be:


a.Street = tmp_char;
tmp_char = a.city;

Some invalid references would be:


a.Province = tmp_char; /* ERROR at compile time
** because attribute 'province'
** is not defined for class 'addr' */

a = null;
a.Street = tmp_char; /* ERROR at runtime because 'a' is
** null, and does not reference
** an object */

Null Reference Variables


When you declare a reference variable without specifying default null, the
variable points to an object whose attributes are automatically initialized with
the default values given in the definition of the object. However, you can set a
reference variable to null. A reference variable that is set to null does not point
to any object. Whenever all reference variables for an object have been
redirected or set to null, OpenROAD frees the associated object, for example,
given the following declarations:
a = Addr;
b = Addr;

The consequences of resetting the variables a and b would be:


a = b; /* The original object for a is freed. Now
** both a and b point to the same object. */
a = null; /* The object created for b still has 1
** reference (b). */
b = null: /* The object created for b is freed. */

As an alternative, you can specify default null on the declaration and a default
object is not created.
You can check for a null reference variable with the is null operator, for
example:
if a is null then
/* processing statements */
endif;

For more information about null reference variables, see Nulls in Expressions.

How You Can Create Objects for Reference Variables


You may need to create an object for a reference variable. For example,
dynamic programs can create fields or forms at runtime by using the Create
method, defined for the Class class. The Create method returns an object of a
specified class.
In the following example, the reference variable a is declared with a default
value of null:
a = Addr default null;

And a new object is created for it:


a = Addr.Create(); /* Creates an Addr object */
a.Street = 'main street';
a.City = 'dallas';

For more information about the Create method, see the Class class Create
Method. Examples of using the Create method are provided in "Creating a
Frame at Runtime" in the Programming Guide.

What is the scope of variables

The scope of a variable is the region of your program in which it is defined.


JavaScript variables have only two scopes.

• Global Variables − A global variable has global scope which means it can be defined
anywhere in your JavaScript code.
• Local Variables − A local variable will be visible only within a function where it is
defined. Function parameters are always local to that function.
Within the body of a function, a local variable takes precedence over a global
variable with the same name. If you declare a local variable or function parameter
with the same name as a global variable, you effectively hide the global variable.

Literal (computer programming)


In computer science, a literal is a notation for representing a fixed value in source
code.[1][2] Almost all programming languages have notations for atomic values such
as integers, floating-point numbers, and strings, and usually for booleans and characters;
some also have notations for elements of enumerated types and compound values such
as arrays, records, and objects. An anonymous function is a literal for the function type.
In contrast to literals, variables or constants are symbols that can take on one of a class
of fixed values, the constant being constrained not to change. Literals are often used to
initialize variables; for example, in the following, 1 is an integer literal and the three
letter string in "cat" is a string literal:

int a = 1;
string s = "cat";

In lexical analysis, literals of a given type are generally a token type, with a grammar
rule, like "a string of digits" for an integer literal. Some literals are specific keywords,
like true for the boolean literal "true".
In some object-oriented languages (like ECMAScript), objects can also be represented by
literals. Methods of this object can be specified in the object literal using function
literals. The brace notation below, which is also used for array literals, is typical for
object literals:

{"cat", "dog"}
{name: "cat", length: 57}

Type Casting:

In typing casting, a data type is converted into another data type by the
programmer using the casting operator during the program design. In typing
casting, the destination data type may be smaller than the source data type
when converting the data type to another data type, that’s why it is also called
narrowing conversion.

Syntax/Declaration:-
destination_datatype = (target_datatype)variable;
(): is a casting operator.
target_datatype: is a data type in which we want to convert the source data
type.

Type Casting example –


float x;
byte y;
...
...
y=(byte)x; //Line 5
In Line 5: you can see that, we are converting float(source) data
type into byte(target) data type.

Type Juggling

PHP is known as a dynamically typed language. Explicit type declaration of a


variable is neither needed nor supported in PHP. Contrary to C, C++ and Java,
type of PHP variable is decided by the value assigned to it, and not other way
around. Further, a variable when assigned value of different type, its type too
changes. This approach of PHP to deal with dynamically changing value of variable
is called type juggling.

$var="Hello"; // variable is string type


$var=100; //same variable now becomes int

Type juggling also takes place during calculation of expression. In this example,
a string variable containing digits is automatically converted to integer for
evaluation of addition expression.

Example
<?php
$var1=100;
$var2="100 days";
$var3=$var1+var2;
var_dump($var3);
?>
Output

This will produce following result −


PHP Notice: A non well formed numeric value encountered in ...
int(200)

Type casting forces a variable to be used as a certain type. Following script shows
example of different type cast operators.

Literals and Identifiers

Literals are defined as a value that is written in the source code, for example, a
number, a string, Boolean or also more advanced constructs, like Object Literals
or Array Literals:

10
‘Vikuman’
true
[‘Apple’, ‘Banana’]
{name: ‘Vikas’, age: ‘24’}

An identifier is a sequence of characters that can be used to identify a


variable, a function, an object. It can start with a letter, the dollar sign ($) or an
underscore _, and it can contain digits. Using Unicode, a letter can be any
allowed char, for example, an emoji 😄
Data Types
Data Types define the type of data a variable can store. PHP allows eight
different types of data types. All of them are discussed below. There are
pre-defined, user-defined, and special data types.

The predefined data types are:

• Boolean
• Integer
• Double
• String

The user-defined (compound) data types are:

• Array
• Objects

The special data types are:

• NULL
• resource

The first five are called simple data types and the last three are compound
data types:

1. Integer: Integers hold only whole numbers including positive and


negative numbers, i.e., numbers without fractional part or decimal point.
They can be decimal (base 10), octal (base 8), or hexadecimal (base 16).
The default base is decimal (base 10). The octal integers can be declared
with leading 0 and the hexadecimal can be declared with leading 0x. The
range of integers must lie between -2^31 to 2^31.

Double: Can hold numbers containing fractional or decimal parts


including positive and negative numbers or a number in exponential form.
By default, the variables add a minimum number of decimal places. The
Double data type is the same as a float as floating-point numbers or real
numbers.

String: Hold letters or any alphabets, even numbers are included. These
are written within double quotes during declaration. The strings can also
be written within single quotes, but they will be treated differently while
printing variables. To clarify this look at the example below.

Boolean: Boolean data types are used in conditional testing. Hold only
two values, either TRUE(1) or FALSE(0). Successful events will
return true and unsuccessful events return false. NULL type values are
also treated as false in Boolean. Apart from NULL, 0 is also considered
false in boolean. If a string is empty then it is also considered false in
boolean data type.
Array: Array is a compound data type that can store multiple values of
the same data type. Below is an example of an array of integers. It
combines a series of data that are related together.

Objects: Objects are defined as instances of user-defined classes that


can hold both values and functions and information for data processing
specific to the class. This is an advanced topic and will be discussed in
detail in further articles. When the objects are created, they inherit all the
properties and behaviours from the class, having different values for all
the properties.

NULL: These are special types of variables that can hold only one value
i.e., NULL. We follow the convention of writing it in capital form, but it’s
case-sensitive. If a variable is created without a value or no value, it is
automatically assigned a value of NULL. It is written in capital letters.

Resources: Resources in PHP are not an exact data type. These are
basically used to store references to some function call or to external PHP
resources. For example, consider a database call. This is an external
resource. Resource variables hold special handles for files and database
connections.
We will discuss resources in detail in further articles.

Flow control statement:

Flow-Control Statements PHP supports a number of traditional programming


constructs for controlling the flow of execution of a program. Conditional statements,
such as if/else and switch, allow a program to execute different pieces of code, or
none at all, depending on some condition. Loops, such as while and for, support the
repeated execution of particular code.
If:
The if statement checks the truthfulness of an expression and, if the expression is
true, evaluates a statement. An if statement looks like: if (expression) statement To
specify an alternative statement to execute when the expression is false, use the else
keyword: if (expression) statement else statement For example: if ($user_validated)
echo "Welcome!"; else echo "Access Forbidden!"; To include more than one
statement in an if statement, use a block —a curly brace-enclosed set of statements:
if ($user_validated) { echo 'Welcome!"; $greeted = 1; } else { echo "Access
Forbidden!"; exit; } PHP provides another syntax for blocks in tests and loops. Instead
of enclosing the block of statements in curly braces, end the if line with a colon (:)
and use a specific keyword to end the block (endif, in this case). For example: if
($user_validated) : echo "Welcome!"; $greeted = 1; else : echo "Access Forbidden!";
exit; endif; Other statements described in this chapter also have similar alternate
style syntax (and ending keywords); they can be useful if you have large blocks of
HTML inside your statements. For example:

First Name: Sophia

Last Name: Lee

Please log in. Because if is a statement, you can chain them: if ($good)
print('Dandy!'); else if ($error) print('Oh, no!'); else print("I'm ambivalent...");
Such chains of if statements are common enough that PHP provides an easier
syntax: the elseif statement. For example, the previous code can be rewritten
as: if ($good) print('Dandy!'); elseif ($error) print('Oh, no!'); else print("I'm
ambivalent..."); The ternary conditional operator (?:) can be used to shorten
simple true/false tests. Take a common situation such as checking to see if a
given variable is true and printing something if it is. With a normal if/else
statement, it looks like this: With the ternary conditional operator, it looks like
this: '.($active ? 'yes':'no').'' ?> Compare the syntax of the two: if (expression)
true_statement else false_statement (expression) ? true_expression :
false_expression The main difference here is that the conditional operator is not
a statement at all. This means that it is used on expressions, and the result of a
complete ternary expression is itself an expression. In the previous example, the
echo statement is inside the if condition, while when used with the ternary
operator, it precedes the expression.

Switch:

switch It often is the case that the value of a single variable may determine one
of a number of different choices (e.g., the variable holds the username and you
want to do something different for each user). The switch statement is designed
for just this situation. A switch statement is given an expression and compares
its value to all cases in the switch; all statements in a matching case are
executed, up to the first break keyword it finds. If none match, and a default is
given, all statements following the default keyword are executed, up to the first
break keyword encountered. For example, suppose you have the following: if
($name == 'ktatroe') // do something elseif ($name == 'rasmus') // do something
elseif ($name == 'ricm') // do something elseif ($name == 'bobk') // do
something You can replace that statement with the following switch statement:
switch($name) { case 'ktatroe': // do something break; case 'rasmus': // do
something break; case 'ricm': // do something break; case 'bobk': // do
something break; } The alternative syntax for this is: switch($name): case
'ktatroe': // do something break; case 'rasmus': // do something break; case
'ricm': // do something break; case 'bobk': // do something break; endswitch;
Because statements are executed from the matching case label to the next
break keyword, you can combine several cases in a fall-through. In the following
example, "yes" is printed when $name is equal to "sylvie" or to "bruno": switch
($name) { case 'sylvie': // fall-through case 'bruno': print('yes'); break; default:
print('no'); break; } Commenting the fact that you are using a fall-through case
in a switch is a good idea, so someone doesn't come along at some point and
add a break, thinking you had forgotten it. You can specify an optional number
of levels for the break keyword to break out of. In this way, a break statement
can break out of several levels of nested switch statements. An example of using
break in this manner is shown in the next section.

For:

The for statement is similar to the while statement, except it adds counter
initialization and counter manipulation expressions, and is often shorter and
easier to read than the equivalent while loop. Here's a while loop that counts
from 0 to 9, printing each number: $counter = 0; while ($counter < 10) { echo
"Counter is $counter\n"; $counter++; } Here's the corresponding, more concise
for loop: for ($counter = 0; $counter < 10; $counter++) echo "Counter is
$counter\n"; The structure of a for statement is: for (start; condition; increment)
statement The expression start is evaluated once, at the beginning of the for
statement. Each time through the loop, the expression condition is tested. If it
is true, the body of the loop is executed; if it is false, the loop ends. The
expression increment is evaluated after the loop body runs. The alternative
syntax of a for statement is: for (expr1; expr2; expr3): statement; ...; endfor; This
program adds the numbers from 1 to 10 using a for loop: $total = 0; for ($i= 1;
$i <= 10; $i++) { $total += $i; } Here's the same loop using the alternate syntax:
$total = 0; for ($i = 1; $i <= 10; $i++): $total += $i; endfor; You can specify multiple
expressions for any of the expressions in a for statement by separating the
expressions with commas. For example: $total = 0; for ($i = 0, $j = 0; $i <= 10;
$i++, $j *= 2) { $total += $j; } You can also leave an expression empty, signaling
that nothing should be done for that phase. In the most degenerate form, the
for statement becomes an infinite loop. You probably don't want to run this
example, as it never stops printing: for (;;) { echo "Can't stop me!
"; } In for loops, as in while loops, you can use the break and continue keywords
to end the loop or the current iteration.
Foreach:

The foreach statement allows you to iterate over elements in an array. The two
forms of foreach statement are discussed in Chapter 5. To loop over an array,
accessing each key, use: foreach ($array as $current) { // ... } The alternate syntax
is: foreach ($array as $current): // ... endforeach; To loop over an array,
accessing both key and value, use: foreach ($array as $key => $value) { // ... }
The alternate syntax is: foreach ($array as $key => $value): // ... endforeach;

Declare:

The declare statement allows you to specify execution directives for a block of
code. The structure of a declare statement is: declare (directive) statement
Currently, there is only one declare form, the ticks directive. Using it, you can
specify how frequently (measured roughly in number of code statements) a tick
function registered with register_tick_function( ) is called. For

example: register_tick_function("some_function"); declare(ticks = 3) { for($i =


0; $i < 10; $i++) { // do something } } In this code, some_function( ) is called after
every third statement is executed.

Exit and return

The exit statement ends execution of the script as soon as it is reached. The return
statement returns from a function or (at the top level of the program) from the script.
The exit statement takes an optional value. If this is a number, it's the exit status of the
process. If it's a string, the value is printed before the process terminates. The exit( )
construct is an alias for die( ): $handle = @mysql_connect("localhost", $USERNAME,
$PASSWORD); if (!$handle) { die("Could not connect to database"); } This is more
commonly written as: $handle = @mysql_connect("localhost", $USERNAME,
$PASSWORD) or die("Could not connect to database");

You might also like