PHP Programming Fundamentals: Data Types, Functions, and Form Handling, Exercises of Database Programming

Database ProgrammingDatabase Programming

Typology: Exercises

2016/2017

Uploaded on 10/02/2017

bagavath-kumar
bagavath-kumar 🇮🇳

2 documents

1 / 88

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Data Types
Scalar Data Types & Compound Data Types
Scalar Data Types:
Integer , float or double ( 1.23/ 10.2e3), boolean, string,unicode(sequence
of unicode characters), binary
Compound Data Types
Array, Objects
Special Data Types
Null, resource
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
pf41
pf42
pf43
pf44
pf45
pf46
pf47
pf48
pf49
pf4a
pf4b
pf4c
pf4d
pf4e
pf4f
pf50
pf51
pf52
pf53
pf54
pf55
pf56
pf57
pf58

Partial preview of the text

Download PHP Programming Fundamentals: Data Types, Functions, and Form Handling and more Exercises Database Programming in PDF only on Docsity!

Data Types

 Scalar Data Types & Compound Data Types Scalar Data Types: Integer , float or double ( 1.23/ 10.2e3), boolean, string,unicode(sequence of unicode characters), binary Compound Data Types Array, Objects Special Data Types Null, resource

Functions

Better code organization – functions allow us to

group blocks of related code that perform a specific

task together.

Reusability – once defined, a function can be called

by a number of scripts in our PHP files. This saves us

time. Ex: database connection..

Easy maintenance- updates to the system only need

to be made in one place.

String Functions

strlen() - to calculate the number of characters inside

a string.

It also includes the blank spaces inside the string.

str_word_count() - Counting Number of Words in a

String

str_replace() - replaces all occurrences of the search

text within the target string.

Ex: <?php

$my_str = “Guru Nanak College I MCA “;

echo str_replace(“I", “I Year ", $my_str);

str_replace(“I ", “I MCA", $my_str, $count); Count- to know how many times the string replacements was performed strrev() - function reverses a string. strpos() - to search for a string or character within a string. If a match is found in the string, this function will return the position of the first match. If no match is found, it will return FALSE. Ex:

Str_repeat(string,repeat) - repeating a string a

specific number of times.

Ex: echo str_repeat(“*”,13);

Strcmp(string1,string2) - It returns output either

greater than zero, less than zero or equal to zero.

substr( string,start,length ) - can display or extract

a string from a particular position.

Converting lowercase into Title Case

Strstr(“string”,”search string”) Find the first occurrence of “search string" inside “string" and return the rest of the string: Ex:

o/p – World! strstr( _string,search,before_search_ )  _before_search -_ Optional. A boolean value whose default is "false". If set to "true", it returns the part of the string before the first occurrence of the _search_ parameter. Ex: O/p:- Hello

MULTIPLE SUBMIT BUTTONS IN A SINGLE FORM

**

**

Max, minPi() - echo(pi())Pow(x,y)Round(number, optional) round(3.4)3 round(3.5)- > 4 Round(1.9562,2)-> 1.

Date Functions

the form data is sent to a web page on the server when the

user clicks on the submit button.

This page(action_page.php) contains a server-side script that

handles the form data:

The Method Attribute –

The method attribute specifies the HTTP method ( GET or

POST ) to be used when submitting the form data:

(or)

When to Use GET?

The default method when submitting form data is GET.

The GET method is restricted to send upto 1024 characters

only.

Never use GET method if you have password

GET can't be used to send binary data, like images or word

documents, to the server.

when GET is used, the submitted form data will be visible in

the page address field(Query String)

Ex: /action_page.php?firstname=Mickey&lastname=Mouse