php - notes
Short Description
notes about web developing php...
Description
1
2
HTML HTML is a not a scripting language or programming language But it is a simply markup language .this markup language with the pair of markup tags. The first Tag is known as opening tag (or) starting tag. The second tag is known as closing (or) end tag. HTML are used to describe the web pages HTML can be written in notepad, notepad++, dream viewer, adov and cs5 HTML file can be saved with .html as its extension The look end of an web page should be same on the all browsers. If it is not same the cross browser compatibility
Tags in html: Heading tags are h1, h2...h6 Ex: - welcome to html . . welcome to html : - this tag is used for horizontal line : - this tag is used for break : - this tag is used for paragraph content : - this tag is used for bold content : - this tag is used for italic content : - this tag is used for connect the style sheets : - this tag is used for JavaScript : - this tag is used for big content : - this tag is used for strong content : - this tag is used for blink content
3
: - this tag is used for delete the content : - this tag is used for strike : - this tag is used for underline content : - this tag is used for insert content : - this tag is used for quotation content : - this tag is used for super content Ex: - (a+b) 2 : - this tag is used for subscript content Ex: - h2o Entities: Entities are used to describe the symbols (or) special characters on to the web page. We have certain symbols are not available on the keyboard. So such symbols can be inserting through entities. We have mainly two types of entities they are 1. Named Entity 2. Number Entity 1. Named Entity: Syntax: - Ampersand + entity name + semicolon Ex: -$ 2. Number Entity: Syntax: - Ampersand + hash + ascci value+ semicolon Ex: - A =>A =>Trademark: tm List Tags: List tags are two types 1. Order list: - Grouping of elements in the form of order wise through number, upper alpha (A) lower alpha (a), upper roman, lower roman is known as order list Ex: - Order list.html
4
List Tags Ordered List Nokia Mototola LG-Mobile Sony 2. Unorder list: - Grouping of elements in the form of disk, square circle are known as unorder list Ex: - unorder list.html List Tags Unordered List PHP HTML JOOMLA
5
MySQL Defination List Terms & Conditions some large text matter write here Definition list: - this is used to maintain the heading the description on to the tag this is dl Definition term: - definition term creates the heading Definition description: -which holds to the description of the content this is dd Dt and dd tags are both child tags of DL Meta tag: - Meta tag is used generate the traffic on to your web page. Meta tags can be embed into the head tag using Meta tag Meta tag helps in search engine ranking on Google page and PTC(pay to click) Ex: - Meta.html Meta Tags
6
We have changed our Website Name from UTI Bank to AXIS Bank ... Sorry for incontinent Please wait for 5 sec it would be Automatically be Redirected Link tags: - links are used to navigate from one page to another page using inter (or) external links The attributes we can pass are Target = “-blank” // new web page Target = “-new”
// new web page
Target = “-self”
// open on same page
Links can also we target to mails and also we search the link on same page Ex: - linktag.html Link Tags Links Navigation Google page || Facebook Page || Tags Content Mail Concept Contact Us Contact Support & Admin
7
Navigating to Search the Link FAQ what is html ? what is php ? what is joomla ? what is ajax ? what is mysql ? what is jquery ? what is java script ? Answer 01: write here some large text matter Back to Top Answer 02: write here some large text matter Back to Top Answer 03: write here some large text matter Answer 04: write here some large text matter Answer 05: write here some large text matter Image tags: - images can be embed into the body tag using image tag. Images have extension of jpg, png, gif etc Placing on image on to the web page can be done by two types they are 1. Absolute path: - working from the working directory you can call the image from any ware with respect its parent directory (or) out of the parent directory (or) external files
8
Ex: image tags image tags absolute path 2. Relative path: - using relative path you can work with images on to the same current working directory (or) sub folders did not out of your parent directory Ex: image tags image tags relation tags
9
Tables create: - tables are used to put down content in tabular structure. Table tag can be embed into your body tag using table row table data (or) content The general attributes that we can pass in tables are Border = “” Width = “” Height = “” Cell padding = “” Cell spacing = “” Align = left/center/right Background = “image path” Fames = “box/group/lhs/rhs/above/below/vsides/hsides Rules = all/middle/bottom Colspan =“” Rowspan = “” Bgcolor = “color name” Ex: table creat employee detailsl
10
s.noNamedesignation 1sureshphp programmer Cell padding: - cell padding is used to maintain the distance between its content and from its wall (or) border Cell spacing: - cell spacing is used to increase the wall (or) the border Frame set: - frame set we can divide the body into no of divisions that are passed as an argument based on rows (or) cols working with frame set you should ensure that body tag in not given Note: - frame set is a depreciated tag and would be working with feature versions Ex: Frameset Tags Iframes: Ex: -
11
Iframes Tags List Page | Links Page Created registration form: - registration.html Register Form New Registration Form First name: E-Mail:
12
Password: Confirm Password: Gender *: Male Female Hobbies: Playing Reading Singing Country: Please select INDIA USA United Kingdom Address: Image Upload:
13
14
15
Css Css stands for cascading style sheet. Css is used to put some styles (or) colors on to the web page. Css can be embed into the html head tag using style tag. There are mainly 3 different flavors to attach this style on to the web page. Which are mainly 1. Internal style sheet 2. External style sheet 3. in-line style sheet 1. Internal style sheet: An internal style sheet should be used when a single document has a unique style. You define internal styles in the head section of an HTML page, by using the tag, like this: hr {color:sienna;} p {margin-left:20px;} body {background-image:url("images/back40.gif");} 2. External style sheet: An external style sheet is ideal when the style is applied to many pages. With an external style sheet, you can change the look of an entire Web site by changing one file. Each page must link to the style sheet using the tag. The tag goes inside the head section: An external style sheet can be written in any text editor. The file should not contain any html tags. Your style sheet should be saved with a .css extension. An example of a style sheet file is shown below:
16
hr {color:sienna;} p {margin-left:20px;} body {background-image:url("images/back40.gif");} 3. in-line style sheet: An inline style loses many of the advantages of style sheets by mixing content with presentation. Use this method sparingly! To use inline styles you use the style attribute in the relevant tag. The style attribute can contain any CSS property. The example shows how to change the color and the left margin of a paragraph: This is a paragraph. We have one more style which is given by default by browsers which is not editable External style sheet can be saved with .css as its extension Syntax: (Attributes) element (or) class (or) id {property: value ;}
CSS Syntax A CSS rule has two main parts: a selector, and one or more declarations:
The selector is normally the HTML element you want to style. Each declaration consists of a property and a value. The property is the style attribute you want to change. Each property has a value. Selector: - selector are identifiers which give styles based on elements, class (denoted by period ‘.’), id (denoted by ‘#’) based on selectors we have Element selector Class selector
17
Class with element selector Id selector Id with element selector Attribute selector Pseudo selector
Element selector: Ex: - element.html Element Selector h1{color:green;} Welcome to my Website Class selector: The class selector is used to specify a style for a group of elements. Unlike the id selector, the class selector is most often used on several elements. This allows you to set a particular style for many HTML elements with the same class. The class selector uses the HTML class attribute, and is defined with a "." In the example below, all HTML elements with class="center" will be center-aligned:
18
Ex: - class-selector.html & Class with element selector: Element Selector h1{color:green;} //element selector .x{color:red;}
// class selector
//.x{font-family:impact;} p.x{font-size:20pt;color:black;}
// Class with element selector
Welcome to my Website This is new Website hello This is my next line Hello my next page Rajesh Id selector: The id selector is used to specify a style for a single, unique element. The id selector uses the id attribute of the HTML element, and is defined with a "#".
19
The style rule below will be applied to the element with id="para1": Ex: - id-selector.html & id with element selector Element Selector h1{color:green;} //element selector .x{color:red;}
// class selector
//.x{font-family:impact;} p.x{font-size:20pt;color:black;} // Class with element selector #g{background:green;}
//id selector
p#g{text-transform:uppercase;} //id with element selector Welcome to my Website This is new Website hello This is my next line Hello my next page Rajesh Amith David
20
Praveen Karthik Attribute selector: Ex: - attribute.html Element Selector .x{ color:deeppink; font-family:impact; } input[type='text']{ color:deeppink; } Name : username :
21
Pseudo selector: Ex: - pseudo.html Element Selector p:first-letter{ font-size:30pt; color:deeppink; font-family:arial black; } p:first-line{ color:orange; } This is my first email to all you guys his is my first email to all you guys his is my first email to all you guys his is my first email to all you guys his is my first email to all you guys
22
Ex2: - pseudo2.html Element Selector a{font-size:20pt;font-weight:bold;} a:link{ color:red; } a:visited{ color:green; } a:active{ color:blue; } a:hover{ color:deepskyblue; text-decoration:none; } Selector | Elements
23
Css ex: first css page H1{color : green;} welcome to my web site some large text matter this is my next element Css sheat sheet: Font-styles :font-style : italic,normal font-variant : small-caps,narmal,small,caps(capital letters) font-weight : normal,lighter,bold, bolder, number(100->light, 900->bolder) font-size : px; font-family : family of font Ex: First CSS Page
24
.x{ font-style:italic; font-variant:small-caps; font-weight:900; font-size:16px; font-family:courier new; } //.y{font:normal normal 100 20pt courier new;} some large text matter some large text matter Text properties:1. letter-spacing : px 2. word-spacing : px 3. line-height : px 4. text-align : left/center/right/justify ->order from left (or) right 5. text- decoration : name, blink,underline,overline,line-through 6. text-transform : capitalize(upper case/lower case(everything convert)) 7.text-indent : : px (distance from line to first letter) The text-align property is used to set the horizontal alignment of a text. Text can be centered, or aligned to the left or right, or justified. When text-align is set to "justify",
25
each line is stretched so that every line has equal width, and the left and right margins are straight (like in magazines and newspapers). The text-decoration property is used to set or remove decorations from text. The textdecoration property is mostly used to remove underlines from links for design purposes: The text-transform property is used to specify uppercase and lowercase letters in a text.It can be used to turn everything into uppercase or lowercase letters, or capitalize the first letter of each word. The text-indentation property is used to specify the indentation of the first line of a text. Ex: -text.html First CSS Page .x{ letter-spacing:1px; word-spacing:3px; line-height:1.1em; text-indent:80px; text-align:justify; text-decoration:none; text-transform:capitalize; } some large text matter
26
Background property: -CSS background properties are used to define the background effects of an element.
background-color : ‘color name’; CSS background properties are used to define the background effects of an element. background-image : url(image path name); The background-image property specifies an image to use as the background of an element. By default, the image is repeated so it covers the entire element. The background image for a page can be set like this: background-repeat : no-repeat,reapt-x,reapt-y,repeat(*); By default, the background-image property repeats an image both horizontally and vertically. Some images should be repeated only horizontally or vertically, or they will look strange, like this: background-attachment : fixed,scroll; background-position :{x,y}left,center,right,bottom,top When using a background image, use an image that does not disturb the text. Showing the image only once is specified by the background-repeat property: //background : order wise Ex: First CSS Page /*body{
27
background-color:silver; background-image:url(2.png); background-repeat:no-repeat; background-attachment:fixed; background-position:280px 80px; }*/ body{ background:gold url(2.png) no-repeat fixed right bottom; } some large text matter some large text matter. some large text matter. some large text matter. some large text matter. List properties: list-style-type : none,disk,circle,square,decimal,upper-alpha,lower-alpha,upper-roman,lowerroman; list-style-position : outside (*) / inside; list-style-image:url(image path name); Ex: - listproperties.html
28
First CSS Page ul.x{ background:#ccc; list-style-type:none; list-style-position:outside; list-style-image:url(tick.png); } ul.x li{ background:gold; padding:5px; margin:2px; } ul.x li.c{ list-style-image:url(cross.png); } We Train PHP We Train CMS that is Joomla,Drupal We Train SAP We don't Train .NET We don't Train Ruby on Rails
29
Box properties: Padding : inside element Margin auto = center Overflow = visible (*), hidden, auto, scroll Ex: BOX properties //body{margin:0px;} p{text-align:center;} .z{ background:#ccc; padding:15px; width:50%; height:80px; margin:auto; overflow:auto; text-align:justify; }
30
Terms & Conditions Some large text matter Border: border-width : px; border-style : solid,groove,inset,outset,double,dotted,dashed; border-color : //border: order wise Ex: - border.html BOX properties .a{ border-width:5px; border-style:solid; border-color:gold; } .b{border:10px dashed red;padding:10px;} .c{ border-bottom:5px double black; padding:10px; }
31
This is a place for social network where people would have the choices to vote there views This is a place for social network where people would have the choices to vote there views This is a place for social network where people would have the choices to vote there views Div tag: - div tag stand for division tag div tag is the block level element. A block level element creates a block with coming left and right breaks in it Ex:- div tag, p tag, h1 to h6, table tag, ul and li tags In-line element: - these particular elements will take the content span only and does not have breaks init Span tag is the natural tag Ex: in-line element h1 { background : green; display : inline;
32
} b { Background: gold; } a.{text-align : center; background : yellow; display : block; } hellohellohellohello hello hello converting block & inline & respectively hello Display property: Visibility : - we have visible (or) hidden Display: - none, in-line, block; Padding : - px Padding:
top 0px
all sides
left 0px
Bottom right
33
Margin: all sides Margin : top right bottom left 0px
0px
0px
0px
Ex:
display property div{ background:blue;color:#fff;padding:10px;font-size:20pt;margin:2px; } .h{visibility:hidden;} .v{visibility:visible;} //.n{display:none;background:#ddd} //.i{display:inline;} Normal Element Hidden Element Visible Element Display Element Please Pay the Bill to avoid late payment charges Display Inline Element
34
Templates: Position properties: - position in css we have absolute relative and fixed position Relative position: - working from the current position we can move the element any ware on to the web page but cannot be moved on the top of the position place Absolute & fixed position: - placing from the current position we can move the element to all corner of the web page and also one top of the position place .once an element declare as fixed (or) absolute this will turn to in-line element and this will also carry ‘7’ index init Ex: - position.html Position properties div{background:blue;color:#fff;font-size:17pt; font-weight:bold;padding:10px;margin:4px;} .r{background:gold;color:#000;position:relative;left:30px;top:120px;} .a{background:blue;position:absolute;top:50px;left:6px;} .f{background:deeppink;color:#000;position:fixed;bottom:0px;right:0px;} Normal Position Absolute Position Relative Position
35
Fixed Position some large text matter some large text matter some large text matter some large text matter Hmenu: Ex: - hmenu.html Position properties ul#hmenu{ list-style-type:none; text-align:center; margin-top:50px; } ul#hmenu li{ display:inline; margin:0px -2px; } ul#hmenu li a{ text-decoration:none; font-size:17pt;
36
padding:10px 20px; font-weight:bold; } ul#hmenu li a:link,ul#hmenu li a:visited,ul#hmenu li a:active{ background:#000; color:#fff; } ul#hmenu li a:hover{ background:#ddd; color:#000; } Home About-Us Products Contact Us Login Vmenu: Ex: - vmenu.html
37
Position properties ul#vmenu{ list-style-type:none; padding:0px; background:gold; width:120px; margin:0px; } ul#vmenu li a{ text-decoration:none; } Home About-Us Products Contact Us Login About: -
38
Ex:- aboutus.html Web Layout body{margin:0px;} div{background:brown;color:#fff;} .h{text-align:center;} .l{background:green;width:150px;float:left;} .r{background:green;width:150px;float:right;} .m{background:#fff;color:#000;margin:0px 150px;padding:20px;text-align:justify;} div.m img#img1{float:right;} div.m img#img2{float:right;padding:10px;clear:both;} Heading Home About-Us Products Contact Us Login
39
Right Content We Are in About us Page Layout: Ex: Web Layout body{margin:0px;} div{background:brown;color:#fff;} .h{text-align:center;} .l{background:green;width:150px;float:left;} .r{background:green;width:150px;float:right;} .m{background:#fff;color:#000;margin:0px 150px;padding:20px;text-align:justify;} div.m img#img1{float:right;} div.m img#img2{float:right;padding:10px;clear:both;} Heading Home
40
About-Us Products Contact Us Login Right Content some large text matter write here
41
JavaScript
JavaScript is client side scripting language. JavaScript is the case sensitive. JavaScript can be used for AJAX integration and validation. JavaScript can be embed into the head tag and body tag using script tag JavaScript can be saved with .js as its extension.
42
Content: Variables Datatypes Operators (Assignment, Arthamatic, Post/Pre [Inc/Dec], Comparission, Relational,
Conditional, Logical,Ternary) Alert,prompt,confirm Built in Functions (Arrays,Date,Math,String) DOM (Document Object Module) Navigator,images,screen,location,history Document – (getElementById, getElementsByTagName, getElementsByName) Events : General Events (onclick(), ondblclick(), onload(), onunload(), onreset(),
onsubmit(), onfocus(), onblur(), onchange()) Mouse Events (onmouseover(), onmousemove(), onmousedown(), onmouseout()
) Key Board Events – (onkeyup() , onkeydown() )
Document. write (): - document.write is the printing method in javascript.which will output statement to the browser Ex: -first.html document.write('This is Called from Head Tag'); Welcome
43
document.write('This is Called from Body Tag'); ext.js:document.write('This is called from External Page'); Variables: - variable are case sensitive. Declaring a variable in JavaScript we have used with var variable name = value; Variables are "containers" for storing information. Ex: - var a = 10; The correct method to declare are Var a = 10; Var_a = 10; Var first-name = ‘suresh’; Var firstName = ‘suresh’; Var $name = ‘suresh’; Wrong method:Var #name = ‘suresh’; Var 1a = 10; Var first name = ‘suresh’; Ex: -variables.html
var = default
44
document.write('This is Called from Head Tag'); firstName = 10; document.write('The Value of a is :'+firstName+''); Welcome Data types: String: - collection of characters inside a single (or) double cotation are known as string working with single cotation and adding double cotation in it is valid.but adding single cotation inside a single cotation is not valid Ex: -datatypes.html var a = 10; document.write(''+a); document.write(' - '); document.write(typeof(a)); document.write('');
45
var f = 10.25; document.write(f); document.write(' - '); document.write(typeof(f)); document.write(''); firstname = 'Rajesh'; document.write(firstname+' - '+typeof(firstname)+''); firstname = firstname+' Kumar'; document.write(firstname+' - '+typeof(firstname)+''); firstname += 'B'; document.write(firstname+' - '+typeof(firstname)+''); document.write('String Methods'); document.write('i\'ll Pay the Bill Tomorrow'); Welcome Operators:Assignment operator: - = is used to assign values. The assignment operator = is used to assign values to JavaScript variables.
46
Assignment operators are used to assign values to JavaScript variables. Ex: document.write('Assignment Operator'); var x = 10; document.write("The Value is : "+x); Arithmetic operator: - The arithmetic operator + is used to add values together. Arithmetic operators are used to perform arithmetic between variables and/or values. Ex: document.write('Arthamatic Operator'); a = 5; b = 3;
47
document.write("Addition : "+(a+b)+''); document.write("Multiplication : "+(a*b)+''); document.write("Division : "+(a/b)+''); document.write("Minus : "+(a-b)+''); document.write("Modulus : "+(a%b)+''); Comparison operator: - Comparison operators are used in logical statements to determine equality or difference between variables or values. Ex: ocument.write('comparision Operator'); if(10 != '10'){ document.write('Correct'); }
else { document.write('Not Correct');
} document.write('Post & Pre Increment');
48
m = 10; n = (m++)+(++m)+(m++)+(++m); document.write('The Value of m is : '+m+'The Value of n is : '+n+''); Relational operator: -
< , > , =
Logical operator: -
&&(and) -- ||(or)
Ternary operator: Syntax: Var a= 10; Type = (a%2 == 0)? ‘even number’: ‘odd number’; //document.write(“the value you entered is : ”+type); document.write(type); Ex: - ternary.html var x = 11; type = (x%2==0)?'Even Number':'Odd Number'; document.write("The Value you have Entered is : "+type+'');
49
student = 'kalpana'; perc = 35; gender = 'f'; status = (perc>55)?'Pass':'Fail'; document.write(student+' you have '+status+'ed the Exam. '+((gender == 'm')?'He':'She')+' Has got '+perc+'% in the Exam'); Ex of pay bill: .x{background:#ddd;color:deeppink;font-weight:bold;font-family:arial black;letterspacing:5px;margin:auto;width:60%;padding:10px;text-align:justify;} credit = 101; curr_date = 15; pay_date = 13; if(credit > 100 && ((curr_date-pay_date0))){
50
document.write("Please Pay the Bill to avoide Late Payment Charges"); } some large text write here Conditions: If else: - whenever a condition is ‘if’ it is true that part of the constructor will be excuted.if condition is fail else part would get executed Conditional statements are used to perform different actions based on different conditions use this statement to execute some code if the condition is true and another code if the condition is false Syntax: If (cond) { //code } else { // code };
51
If else if: - if else if (or) ladder condition will take more than one condition (or) multiple conditions. If all the conditions fail in if else if constructor then only else part get executed use this statement to select one of many blocks of code to be executed Syntax: If(cond) { //code } else if (cond) { //code } else if (cond) { //code } . . . else {
52
//default value; } Switch: - use the case in-order wise. this is main concept in switch case use this statement to select one of many blocks of code to be executed Conditional statements are used to perform different actions based on different conditions. Use the switch statement to select one of many blocks of code to be executed. Syntax: switch(n) { case 1 execute code block 1 break; case 2: execute code block 2 break; default: code to be executed if n is different from case 1 and 2 } Ex: type = 'ddlj'; switch (type){ case 'Ravan': document.write('This is a good Movie ... Review Rating is : 5 star'); break; case 'Titanic': document.write('This is a Holly wood Movie ... Review Rating is : 5 star');
53
break; case 'don': document.write('This is a good Movie ... Review Rating is : 4 star'); break; case 'rambo': document.write('This is a good Movie ... Review Rating is : 3 star'); break; case 100: document.write('This is a 100 good Movie ... Review Rating is : 3 star'); break; case 1: document.write('This is a 3 good Movie ... Review Rating is : 3 star'); break; case 2: document.write('This is a 2 good Movie ... Review Rating is : 3 star'); break; default: document.write('Movie information is not Available'); break; } Looping methods: While:
do-while:
54
Syntax:
Syntax:
Initialize method
Initialize
While (cond)
do
{
{ //code //code
}
}
While: - Working with while loops it will first check the initialize part and checks the condition. If condition is true it will get into the constructor and takes place until condition fail and comes out of the constructor. loops through a block of code while a specified condition is true Do-while: -this will also checks the initialize part .but for only first time it will get into the constructor and execute the code and checks the conditions later and if condition is true looping takes place (or) else it come out of the constructor with at least single time execution code For-loop: - for loop first initialize condition an inc/dec will be done on same (single) line for the every first time it will initialize with part them check within condition if condition is true the constructor will get excuted.condition fail will come out of the for loop (constructor) Loops execute a block of code a specified number of times, or while a specified condition is true. Syntax: For (initialize; condition; inc/dec ) { //code } Ex: -
55
document.write("Day - "); document.write("Day"); day = 1; while(day=1920;year--){ document.write(""+year+""); }
56
document.write(""); Array: - a variable which can hold more than one value is none as array (or) super variable as array can be defined is JavaScript as Var a = new Array (values);
// a->super variable
To fined the length of the array we can go with length = array name.length; If the array index is been initialize more than the current index++ then memory is vested in JavaScript In arrays initializing string index the printing method will not work in JavaScript Ex: - document.write() (or) looping method will not able to print string indexes While, do-while , for-loop will not print string indexes in JavaScript so to print string indexes we can go with Syntax: - for (var name in Array name) For it is key word in JavaScript which will print the string index The Array object is used to store multiple values in a single variable. An array is a special variable, which can hold more than one value, at a time. Create an Array An array can be defined in three ways. The following code creates an Array object called myCars: 1: var myCars=new Array(); // regular array (add an optional integer myCars[0]="Saab";
// argument to control array's size)
myCars[1]="Volvo"; myCars[2]="BMW"; 2: var myCars=new Array("Saab","Volvo","BMW"); // condensed array 3: var myCars=["Saab","Volvo","BMW"]; // literal array Ex: - Array.html
57
var a = new Array(10,20,30,40); document.write('The Array is : '+a+''); document.write('Length of Array : '+a.length+''); document.write('Index at 2 : '+a[2]+''); a[2] = a[2]*2; document.write('The Array is : '+a+''); a[4] = 'New Value'; document.write('The Array is : '+a+''); var b = new Array(); b[0] = 100; b[1] = 200; b[2] = 300; b[3] = 400; b['Name'] = 'Rajesh'; b['Age'] = 30; b[7] = 700; b[10] = 1000; document.write('Single string Index : '+b['Name']+''); document.write('The Array is : '+b+''); for(i=0;i Get Element ById DOCUMENTS-----------> GetElementByTagName NAVIGATOR------------ > GetElementByName EMBED Ex: -dom.html function dochange(){ document.testForm.fname.value = alert("Please Enter"); document.testForm.fname.value = 'Enter Name'; document.testForm.lname.style.border="2px solid red"; document.testForm.lname.style.width="200px"; } First Name : Last Name :
72
Get Element ById:- this particular function will match the id of the element and that particular matching function will get executed Ex: - getElementById.html function dochange(){ var x = document.getElementById('test').value; document.getElementById('test').value = x.toUpperCase(); document.getElementById('test').style.color = 'red'; } First Name : First Name : GetElementByTagName:- this particular function will match tag name and excute the function which we are passing as a tag name Ex: - getElementsByTagName.html function dochange(){ var a = document.getElementsByTagName('div');
73
for(i=0;i10){ m = s.substr(0,10); document.testForm.Msg.value = m; c = 0; } document.testForm.count.value = c;
79
} Gallery create: Ex: - gallery.html Gallery Thumb View
80
Gallery.css: body{ background:lightblue; margin:0px; } .header{ background:darkblue; height:80px; color:#fff; text-align:center; font-size:18pt; font-family:courier new;
81
letter-spacing:5px; font-weight:bold; line-height:70px; } .thumb{ text-align:center;margin:20px 0px 10px 0px; } .thumb img{ width:120px; height:100px; cursor:pointer; } .big{ text-align:center; } .big img{ width:400px; height:300px; } .butob{ margin-bottom:10px; }
82
.buto{ font-size:18pt; padding:8px 20px; background:#000; color:#fff; } .buto:hover{ background:#ddd; color:#000; cursor:pointer; } gallery.js: function alterImage(id,source){ document.getElementById(id).src = source; } function zoom(id,type){ var min_W = 120; var min_H = 100; var max_W = 1000; var max_H = 900; var n_W = 400; var n_H = 300;
83
img = document.getElementById(id); var curr_W = parseInt(img.width); var curr_H = parseInt(img.height); switch (type){ case '+': new_W = curr_W+(curr_W*.1); new_H = curr_H+(curr_H*.1); break; case '-': new_W = curr_W-(curr_W*.1); new_H = curr_H-(curr_H*.1); break; case '0': new_W = n_W; new_H = n_H; break; } if((new_Wmax_H)){ }
else { img.style.width = new_W; img.style.height = new_H;
}
84
}
DHTML: innerHTML.html function showText(v){ document.getElementById('Msg').innerHTML = v; } First Name : innerHTML2.html function showText(v){ len = v.length; //alert(len); if(lenplatform(windows,linux,mac,solaries) a----------------------------->apache(web server) m---------------------------->mysql(database file) p---------------------------->perl(perl scripting in php) p---------------------------->php/my admin (web database tool) php current version is 5.3.8
wamp: - wamp stands for w---------------------------->window exv a----------------------------->apache(web server) m---------------------------->mysql(database file) p---------------------------->php/my admin (web database tool) Mamp: - mamp stands for m----------------------------->mac ‘os’ a----------------------------->apache(web server) m---------------------------->mysql(database file) p---------------------------->php/my admin (web database tool) Apache contain the 1-65535 ports 1-1024 pre-reserved ports Tem: - temp holds session details & temp upload files Htdocs: - after installing xampp we have to store our files into the folder called htdocs. Once files are saved in htdocs we can open with the location path as
105
http://localhost/abc(folder name)/first.php
echo:-echo is the output method in php
Basic PHP Syntax: echo “javascript way of writtting php”;
Comments in PHP In PHP, we use // to make a one-line comment or /* and */ to make a comment block: Printing methods in php: Echo:-echo as the arguments can print multiple arguments. Echo as a function can print only one argument Print: -print as an argument can print only one argument.print also a function Ex: - print”arg”; Printf: - printf will take formatting string with respected values as print Ex: -printf(“(int%d) (float%f) (string %s) (asci%c)”); Print-r: - print-r will print array of string Ex: - $g = array (10,20,30,true,’kalam’); Print-r($g); Var-dump: -it is also printing method which is used debugging the errors very easily. This not used in production level (live environmental) Ex: - var-dump($g); Printing Methods in PHP Controlling: Ex: - controlling.php b{color:green;} This is Bold Tag
108
Alternate Method The 1st is Executed The 2nd is Executed
109
Variables: Variables are "containers" for storing information. Variables in PHP starts with a $ sign, followed by the name of the variable The variable name must begin with a letter or the underscore character A variable name can only contain alpha-numeric characters and underscores (A-z, 0-9,
and _) A variable name should not contain spaces Variable names are case sensitive (y and Y are two different variables) Ex: - variables.php Variables in php
110
var a = 15; document.write('The Value of a is : '+a+''); In PHP, a variable does not need to be declared before adding a value to it. In the example above, notice that we did not have to tell PHP which data type the variable is. PHP automatically converts the variable to the correct data type, depending on its value. In a strongly typed programming language, you have to declare (define) the type and name of the variable before using it. PHP has four different variable
local
global
static
Local variable: - A variable declared within a PHP function is local and can only be accessed within that function. Ex:- localvariable.php Static variable: - When a function is completed, all of its variables are normally deleted. However, sometimes you want a local variable to not be deleted. To do this, use the static keyword when you first declare the variable. Ex: - staticvariable.php Global variable: - Global scope refers to any variable that is defined outside of any function. Global variables can be accessed from any part of the script that is not inside a function.
112
To access a global variable from within a function, use the global keyword: Ex: - global.php 4. Super global array of variable: -$global is the super global array variable. This is the predefined keyword. In php we have mainly some of the super global variables. This can be used with their keywords. i) $_EVN: - this is used for getting the information of your operating system ($_ENV (PATH)) ii) $_SERVER: - will give you the information about your server(apache information) iii) $_GET: - it is used for form processing through get method (or) query string iv) $_POST: -this is used for form processing through post method in secure manner v) $_REQUEST: -will send the form through both get and post and cookie
113
vi)$_COOKIE: - this is used to get the information about the browser who is using the web(computer) vii)$_SESSION: -it is used to get the information of the user in between login and logout details are store at server machine Operators:1. Assignment operator: 2. Arithmetic operator:
= is used to assign values to variables in PHP +,-,/,*,%
3. Increment & decrement operator:
i++,++I & i--, --i
4. Comparison operator:
==,!= ,===
5. Relational operator:
=,
6. Logical operator:
&&, ||, and, or
7. Error handling operator: 8. scope resolution & this operator:
::----->scope, &------->this
Ex: -operator.php
117
Type costing: - conversion of the one data type into another data type is known as type costing. in php we have mainly two types of costing 1. Temporary type costing 2. Permanent type costing 1. Temporary type costing: - costing which can be done for single step by pre-defined the data type keyword. That particular variable will hold Temporary type costing Ex : - temporary.php
118
2. Permanent type costing: - this can be done by using pre-defined key-word set type.which hold two arguments Syntax: - set type (var name,’int’); Ex: - Permanent type costing.php Type juggling: -conversion of data types by using expression to another data types are known as type juggling
119
Ex: -typejuggling.php Variable validation function: i) Isset: -Isset of variables will check with the variable initialize are not and return Boolean ii) empty(var name): - empty function will check the variable are not and return Boolean iii) Unset (var name): -this function will remove the variable (or) delete the variable (or) initialize variable iv) get type(var name): - this function will let us known the argument the data type in the form of string .this should be used because the coming variable this would be depreciated Ex: -variable_validation.php Data types: -php supports mainly 8 kinds of data types among which four are stable data types, two are compound data types and another two are special data types Stable data types: i) int (or) integer ii) Float (or) real (or) decimal iii) Boolean data types iv) string data types i) int (or) integer:- all non decimal values . range in between 2(32-1) to -2(32-1) ex: ii) Float (or) real (or) decimal: -all decimal values. Range in between 10(38) to 10(-38) ex: iii) Boolean data types: -boolean data types written in the form of true (or) false Ex: iv) String data types: - a collection of characters enclose in between single (or) double cotations are known as string data types Ex: Compound data types: - compound data types again two types 1. Array data type
123
2. Object data type 1. Array data type: - array data type which can hold more than one value. In php we have mainly 3 kinds of arrays i) Numerical array ii) Associative array iii) Mixed array Declaring an array in php can be done by two types array as the function array as a square bracket i) Numerical array: A numeric array stores each array element with a numeric index. There are two methods to create a numeric array. 1. In the following example the index are automatically assigned (the index starts at 0): $cars=array("Saab","Volvo","BMW","Toyota");
2. In the following example we assign the index manually: $cars[0]="Saab"; $cars[1]="Volvo"; $cars[2]="BMW"; $cars[3]="Toyota"; Ex: ii) Associative array: - An associative array, each ID key is associated with a value. When storing data about specific named values, a numerical array is not always the best way to do it. With associative arrays we can use the values as keys and assign values to them.
Example 1 In this example we use an array to assign ages to the different persons: $ages = array("Peter"=>32, "Quagmire"=>30, "Joe"=>34);
Example 2 This example is the same as example 1, but shows a different way of creating the array: $ages['Peter'] = "32"; $ages['Quagmire'] = "30"; $ages['Joe'] = "34"; The ID keys can be used in a script: The code above will output: Peter is 32 years old.
125
iii) Mixed array: - mixed array is nothing but combination of numerical & associative array are known as mixed array Ex:- mixedarrays.php 2. Object data type: - object is an instance of class. Class can be denoted with in class name. Collection of variables and functions are known as class. Calling class name should be create an object variable then that particular variable is known as object variable
126
Ex: Special data types: - special data types are again two types i) Resource data types ii) Null data types i) Resource data types:- resource data type is calling an external variable value into another variable using (&) resource variable ii) Null data types:- this is the pre-defined key-word data type. When a variable not initialize and by asking through printing method. This will result in null value
127
ex: Constant: Define: - define is the pre-defined key-word in php. This will take two arguments. The first argument being the constant identifier which identifier its second argument value. We can pass third argument as Boolean to make case in-sensitive Ex:- constant.php About us we at are in training ........ Contact Us
129
street ...... FAQ what we do at Conditions: - Conditional statements are used to perform different actions based on different conditions If condition: IN PHP
IN PERL
If (cond)
if (cond) :
{
//code
//code
else if (code) :
}
//code
else if (cond) {
//code
//code } else (cond) { //code } Switch condition: Syntax: -
else (cond) :
end else if ;
130
switch (cond) : {
switch (cond): |
Case1 :
| //code
Break;
| |
Case2: //code Break; | | Default: //code } Ex: While condition: - The while loop executes a block of code while a condition is true Syntax: While (cond) {
//code inc/dec
//const code inc/dec } Ex:
while (cond):
endwhile
132
Output: The number is 1 The number is 2 The number is 3 The number is 4 The number is 5 Do-while condition: - The do...while statement will always execute the block of code once, it will then check the condition, and repeat the loop while the condition is true. Syntax: Do
do:
{
//code
inc/dee //code
endoowhile(cond);
} While (cond) Example The example below defines a loop that starts with i=1. It will then increment i with 1, and write some output. Then the condition is checked, and the loop will continue to run as long as i is less than, or equal to 5: Output: The number is 2 The number is 3 The number is 4 The number is 5 The number is 6 For loop: - Loops execute a block of code a specified number of times, or while a specified condition is true. The for loop is used when you know in advance how many times the script should run. Syntax: For(initialize;cond;inc/dec) //code
for(initialize;code;inc/dec //code end for
Example The example below defines a loop that starts with i=1. The loop will continue to run as long as i is less than, or equal to 5. i will increase by 1 each time the loop runs: Output: The number is 1 The number is 2 The number is 3 The number is 4 The number is 5 Ex: -conditions.php for each:- for each is usefull for all non-sequence data of an array. Associative array ,numerical array object data of an array The general syntax is foreach (arrayName as arr[value])) { echo arr [value]; } Another syntax is foreach (arrayname as key=>value) { echo key’-‘value
(or)
echo “key-value”;
} Ex: -foreach.php Functions: -functions are case in-sensitive. Function once can be declare con’t be re-declare in the program The real power of PHP comes from its functions. In PHP, there are more than 700 built-in functions
To keep the script from being executed when the page loads, you can put it into a function. A function will be executed by a call to the function. You may call a function from anywhere within a page.
Give the function a name that reflects what the function does
The function name can start with a letter or underscore (not a number)
Syntax: function function name (arg) { //code Return value }
137
There are mainly 8 kinds of functions in php 1. Conditional function: - a function which is enclose inside condition is considered as conditional function Ex: - conditional.php
View more...
Comments