Embed presentation
Downloaded 93 times
















![17input[type='text']{color:deeppink;}</style></head><body>Name : <input type='text’ name='name' class='x'><br>username : <input type='text' name='uname'><br></body></html>7.Pseudo selector :Ex : pseudo.html<html><head><title>Pseudo Selector</title><style>p:first-letter{font-size:30pt;color:deeppink;font-family:arial black;}p:first-line{color:orange;}](/image.pl?url=https%3a%2f%2fimage.slidesharecdn.com%2fphpnotes-161223104036%2f75%2fPHP-HTML-CSS-Notes-17-2048.jpg&f=jpg&w=240)








![26JavaScript 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 usingscript tag. JavaScript can be saved with .js as its extension.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 is outputstatement to the browser.Ex: first.html<html><head>](/image.pl?url=https%3a%2f%2fimage.slidesharecdn.com%2fphpnotes-161223104036%2f75%2fPHP-HTML-CSS-Notes-26-2048.jpg&f=jpg&w=240)









![36 While, do-while , for-loop will not print string indexes inJavaScript so to print string indexes we can go withSyntax: - for (var name in Array name) For is key word in JavaScript which will print the string index The Array object is used to store multiple values in a singlevariable. An array is a special variable, which can hold more than onevalue, 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 integermyCars[0]="Saab"; // argument to control array's size)myCars[1]="Volvo";myCars[2]="BMW";2: var myCars=new Array("Saab","Volvo","BMW"); // condensedarray3: var myCars=["Saab","Volvo","BMW"]; // literal arrayEx : Array.html<script>var a = new Array(10,20,30,40);document.write('The Array is : '+a+'<br>');document.write('Length of Array : '+a.length+'<br>');document.write('Index at 2 : '+a[2]+'<br>');a[2] = a[2]*2;document.write('The Array is : '+a+'<br>');a[4] = 'New Value';](/image.pl?url=https%3a%2f%2fimage.slidesharecdn.com%2fphpnotes-161223104036%2f75%2fPHP-HTML-CSS-Notes-36-2048.jpg&f=jpg&w=240)
![37document.write('The Array is : '+a+'<br>');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('<hr>Single string Index : '+b['Name']+'<hr>');document.write('The Array is : '+b+'<br>');for(i=0;i<b.length;i++){document.write('Index at : '+i+' = '+b[i]+'<br>');}document.write('<hr>');for(c in b){document.write(c+' = '+b[c]+'<br>');}document.write('<hr>');var d = [10,20,30];document.write('The Array in d is : '+d+'<br>');document.write('The Array in d is : '+d.length+'<br>');document.write('<hr>');](/image.pl?url=https%3a%2f%2fimage.slidesharecdn.com%2fphpnotes-161223104036%2f75%2fPHP-HTML-CSS-Notes-37-2048.jpg&f=jpg&w=240)
![38var e = {'Name':'Rajesh','Age':30,10:20,'Status':'Active'};document.write('The Array in d is : '+e+'<br>');for(i=0;i<e.length;i++){document.write('Index at : '+i+' = '+e[i]+'<br>');}for(c in e){document.write(c+' = '+e[c]+'<br>');}</script>Double dimensional array:An array can have more than one array is called double dimensionalarray.Ex : douledimensionarray.html<html><head><script>var a =[[1,'Ajay',[45,62,49,72,55,84]],[2,'Rajesh',[48,62,94,72,38,62]],[3,'Suresh',[48,63,82,97,45,28]]];//document.write(a[1][1]);document.write('Name is : '+a[2][1]);document.write("<table border='1' align='center' width='60%' >");document.write("<tr><th colspan='9'>Student Marks Memo Report</th> ");](/image.pl?url=https%3a%2f%2fimage.slidesharecdn.com%2fphpnotes-161223104036%2f75%2fPHP-HTML-CSS-Notes-38-2048.jpg&f=jpg&w=240)
![39document.write("<tr><td rowspan='2'>Roll No</td> <tdrowspan='2'>Name</td><td colspan='6'align='center'>Subjects</td><td rowspan='2'>Pass/Fail</td></tr>");document.write("<tr><td>English</td><td>Hindi</td><td>Telugu</td> <td>Maths</td><td>Science</td><td>Social</td></tr>");document.write("<tr><td>"+a[0][0]+"</td></tr>");</script></head><body><tr><td><script>document.write(a[1][0]);</script></td><td><script>document.write(a[1][1]);</script></td></tr></table></body></html>Array built-in Functions :Join : Join is the pre-defined key-word in the JavaScript .which willconvert the given array into the separator passed default separator iscoma (,).Concat : concat is joining more than array in single array is calledconcat.Reverse : reverse in JavaScript the array last being is first. First islast without (descending order) the original array will also getaffected. If we use reverse function.Sort : sort is nothing but given the order is ascending order .Unshift : unshift will add the value at the starting of the array. Thevariable use for unshift will holds the length of the array and theoriginal array would get affected.](/image.pl?url=https%3a%2f%2fimage.slidesharecdn.com%2fphpnotes-161223104036%2f75%2fPHP-HTML-CSS-Notes-39-2048.jpg&f=jpg&w=240)







![47r('<hr><h2><u>Slice Function([begin, stop]) </u></h2>');r('Slice(4) = '+str.slice(4));r('Slice(4,8) = '+str.slice(4,8));r('Slice(-9) = '+str.slice(-9));r('Slice(-9,8) = '+str.slice(-9,8));r('Slice(-9,-3) = '+str.slice(-9,-3));r('<hr><h2><u>Substring Function([From, to]) </u></h2>');r('substring(4) = '+str.substring(4));r('substring(4,8) = '+str.substring(4,8));r('substring(4,2) = '+str.substring(4,2));//r('substring(-9) = '+str.substring(-9));r('<hr><h2><u>substr([start, length]) </u></h2>');r('substr(4) = '+str.substr(4));r('substr(5,8) = '+str.substr(5,8));r('substr(-9) = '+str.substr(-9));r('substr(-9,2) = '+str.substr(-9,1));r('CharAt(0) = '+str.charAt(1));r('charCodeAt(1) = '+str.charCodeAt(1)); //ascill Value of Indexmob = 'Z123456789';r('charCodeAt = '+mob.charCodeAt(0));r('Indexof = '+str.indexOf('T'));//-1r('lastIndexof = '+str.lastIndexOf('t'));r('indexOf = '+str.indexOf('t',9));r('Search = '+str.search('z'));//-1](/image.pl?url=https%3a%2f%2fimage.slidesharecdn.com%2fphpnotes-161223104036%2f75%2fPHP-HTML-CSS-Notes-47-2048.jpg&f=jpg&w=240)




![52</form></body>GetElementByTagName :This particular function will match tag name and excute the functionwhich we are passing as a tag nameEx : getElementsByTagName.html<script>function dochange(){var a = document.getElementsByTagName('div');for(i=0;i<a.length;i++){a[i].style.width = '400px';a[i].style.background = '#ddd';a[i].style.border = '4px dotted green';}}</script><body onmouseover='dochange();'><h1>Welcome to My Web Page</h1><p>This is my First Page</p><p>This is my First Page</p><p>This is my First Page</p><p>This is my First Page</p><div>What is Social Hub</div></body>](/image.pl?url=https%3a%2f%2fimage.slidesharecdn.com%2fphpnotes-161223104036%2f75%2fPHP-HTML-CSS-Notes-52-2048.jpg&f=jpg&w=240)
![53GetElementByName :This particular function will match element name and that part of thefunction will get excutes.Ex : getElementsByName.html<script>function dochange(){var a = document.getElementsByName('x');for(i=0;i<a.length;i++){a[i].style.width = '400px';a[i].style.background = '#ddd';a[i].style.border = '4px dotted green';}}</script><body onmouseover='dochange();'><h1>Welcome to My Web Page</h1><p>This is my First Page</p><p>This is my First Page</p><p>This is my First Page</p><p>This is my First Page</p><div>What is Social Hub</div></body>Note 1 : As ids are unique we have singular matching so we cangetElementById as singular.](/image.pl?url=https%3a%2f%2fimage.slidesharecdn.com%2fphpnotes-161223104036%2f75%2fPHP-HTML-CSS-Notes-53-2048.jpg&f=jpg&w=240)













![67echo 'The Value of $x = ',$x,'<br>';function test(){//global $x;echo 'The Value of $x inside Function = ',$x,'<br>';echo '$GLOBALS["x"] = ',$GLOBALS['x'],'<br>';}test();?>Super global array variable : ‘$ global’ is the super global arrayvariable. This is the pre-defined keyword. In php we have mainlysome of the super global variables. This can be used with theirkeywords.i) $_EVN : This is used for getting the information of your operatingsystem ($_ENV (PATH))ii) $_SERVER : This will give you the information about yourserver(apache information)iii) $_GET : It is used for form processing through get method (or)query stringiv) $_POST : This is used for form processing through post methodin secure mannerv) $_REQUEST : It will send the form through both get and post andcookievi)$_COOKIE : This is used to get the information about the browserwho is using the web(computer)vii)$_SESSION : It is used to get the information of the user inbetween login and logout details are store at server machine.](/image.pl?url=https%3a%2f%2fimage.slidesharecdn.com%2fphpnotes-161223104036%2f75%2fPHP-HTML-CSS-Notes-67-2048.jpg&f=jpg&w=240)

![69echo 'My name is : ',$name,'<br>';echo '<h1 align="center">Arthamatic Operator</h1>';echo 'The value of 2+3 : ',2+3,'<br>';echo 'The Value of 2-3 : ',2-3,'<br>';echo 'The Value of 2/3 : ',2/3,'<br>';echo 'The Value of 2*3 : ',2*3,'<br>';echo 'The Value of 2%3 : ',2%3,'<br>';echo '<h1 align="center">Increment & Decrement [INC/DEC]</h1>';echo '<h2>POST & PRE increment</h2>';$x = 10;echo 'The Value of $x = ',$x,'<br>';echo 'The Value of $x++ = ',$x++,'<br>';echo 'The Value of $x = ',$x,'<br>';echo 'The Value of ++$x = ',++$x,'<br>';echo 'The Value of $x = ',$x,'<br>';echo '<h2>POST & PRE Decrement</h2>';echo 'The Value of $x-- = ',$x--,'<br>';echo 'The Value of $x = ',$x,'<br>';echo 'The Value of --$x = ',--$x,'<br>';echo 'The Value of $x = ',$x,'<br>';echo '<h1 align="center">Comparision Operator</h1>';](/image.pl?url=https%3a%2f%2fimage.slidesharecdn.com%2fphpnotes-161223104036%2f75%2fPHP-HTML-CSS-Notes-69-2048.jpg&f=jpg&w=240)








![78iii) Mixed arrayDeclaring an array in php can be done by two types array as the function array as a square bracketi) Numerical array :A numeric array stores each array element with a numeric index.There are two methods to create a numeric array. In the following example the index are automatically assigned(the index starts at 0):$cars=array("Saab","Volvo","BMW","Toyota"); In the following example we assign the index manually:$cars[0]="Saab";$cars[1]="Volvo";$cars[2]="BMW";$cars[3]="Toyota";Ex :<?php$cars[0]="Saab";$cars[1]="Volvo";$cars[2]="BMW";$cars[3]="Toyota";echo $cars[0] . " and " . $cars[1] . " are Swedish cars.";?>ii) Associative array :An associative array, each ID key is associated with a value.](/image.pl?url=https%3a%2f%2fimage.slidesharecdn.com%2fphpnotes-161223104036%2f75%2fPHP-HTML-CSS-Notes-78-2048.jpg&f=jpg&w=240)
![79When storing data about specific named values, a numerical array isnot always the best way to do it.With associative arrays we can use the values as keys and assignvalues to them.Example 1In this example we use an array to assign ages to the differentpersons:$ages = array("Peter"=>32, "Quagmire"=>30, "Joe"=>34);Example 2This example is the same as example 1, but shows a different way ofcreating the array:$ages['Peter'] = "32";$ages['Quagmire'] = "30";$ages['Joe'] = "34";The ID keys can be used in a script:<?php$ages['Peter'] = "32";$ages['Quagmire'] = "30";$ages['Joe'] = "34";echo "Peter is " . $ages['Peter'] . " years old.";?>The code above will output:Peter is 32 years old.iii) Mixed array :Mixed array is nothing but combination of numerical & associativearray is known as mixed array.](/image.pl?url=https%3a%2f%2fimage.slidesharecdn.com%2fphpnotes-161223104036%2f75%2fPHP-HTML-CSS-Notes-79-2048.jpg&f=jpg&w=240)









![89f)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 isforeach (arrayName as arr[value])){echo arr [value];}Another syntax isforeach (arrayname as key=>value){echo key’-‘value (or) echo “key-value”;}Ex : foreach.php<?php$a = array("Name"=>"Rajesh","Age"=>30);/*foreach(arrayname as value){echo arr[value];}*/foreach($a as $v){echo $v,'<br>';}echo '<hr>';/*foreach(arrayname as key=>value){echo key,' - ',value;}*/foreach($a as $k=>$v){](/image.pl?url=https%3a%2f%2fimage.slidesharecdn.com%2fphpnotes-161223104036%2f75%2fPHP-HTML-CSS-Notes-89-2048.jpg&f=jpg&w=240)













![103echo 'Do we have Value with some :',var_dump(in_array('Male',$a)),'<br>';$a =array('Name'=>'Rajesh','Age'=>30,'Status'=>'Active','Email'=>'Raj@gmail.com','Gender'=>'Male');r(array_keys($a),'Array Keys Calling');r(array_values($a),'Array Value Calling');$str = 'Hey i am from India & my name is Praveen';$b = explode(" ",$str);//print_r($b);echo '<br>';echo 'The Length of your total Words = ',count($b),'<br><hr>';for($i=0;$i<count($b);$i++){echo 'The index at ',$i,' = ',$b[$i],'<br>';}$a =array('raj@gmail.com','amith@gmail.com','raju@gmail.com','suresh@gmail.com','raj@gmail.com','amith@gmail.com','raju@gmail.com','suresh@gmail.com');print_r($a);$b = implode(',',$a);<br><br>To : <input type='text' name='name' value='<?php echo $b;?>'size='60'/><hr><?php$a = array('born','child','teen','father','dead');r($a,'Normal Array');](/image.pl?url=https%3a%2f%2fimage.slidesharecdn.com%2fphpnotes-161223104036%2f75%2fPHP-HTML-CSS-Notes-103-2048.jpg&f=jpg&w=240)












![116Super Globals :Difference between GET and POST :GET POST1.GET data transfers through URL. POST data is sendthrough request headers2.GET is insecure POST is secure3.File cannot be transfered using GET Files can betransfered4.Limited data can be send based on length We can send hugedata(8MB) which can be scaledof URL supported by browser(2KB). up by usingPOST_MAX_SIZE5.It is fast It is not as fast as GET.6.$_GET is used for accessing $_POST is used for accessingthe GET parameters the POST parametersGET Ex :-----get.php<?phpif(isset($_GET['submit'])){echo 'Name : ',$_GET['fname'],'<br>';echo 'Email Address : ',$_GET['email'],'<br>';$gend = ($_GET['gender'] == 'm')?'Male':'Female';echo 'Gender : ',$gend,'<br>';}](/image.pl?url=https%3a%2f%2fimage.slidesharecdn.com%2fphpnotes-161223104036%2f75%2fPHP-HTML-CSS-Notes-116-2048.jpg&f=jpg&w=240)
![117echo '<hr>';echo urldecode($_SERVER['QUERY_STRING']);echo '<hr><br>';?>-----get.html<form method='GET' action='get.php'>Name : <input type='text' name='fname' value=''><br>E-Mail : <input type='text' name='email' value=''><br>Gender : <input type='radio' name='gender' value='m'> Male <inputtype='radio' name='gender' value='f'> Female<br><input type='submit' name='submit' value='Register !'></form>POST Ex :-----post.php<?phpif(isset($_POST['submit'])){echo 'Name : ',$_POST['fname'],'<br>';echo 'Email Address : ',$_POST['email'],'<br>';$gend = ($_POST['gender']=='m')?'Male':'Female';echo 'Gender : ',$gend,'<br>';$a = $_POST['course'];echo $a,'<br><hr>';print_r($a);}echo '<hr>';echo 'The query string : ',$_SERVER['QUERY_STRING'],'<br>';](/image.pl?url=https%3a%2f%2fimage.slidesharecdn.com%2fphpnotes-161223104036%2f75%2fPHP-HTML-CSS-Notes-117-2048.jpg&f=jpg&w=240)
![118?>-----post.html<form method='POST' action='post.php'/>Name : <input type='text' name='fname' value=''/><br>E-Mail : <input type='text' name='email' value=''/><br>Gender : <input type='radio' name='gender' value='m'/> Male <inputtype='radio' name='gender' value='f'/> Female <br>Hobbies : <br><input type='checkbox' name='course[]' value='c'/> C-Language <br><input type='checkbox' name='course[]' value='p'/> PHP <br><input type='checkbox' name='course[]' value='j'/> Java <br><input type='submit' name='submit' value='Register'/></form>Server Variables :-----servervariables.php<?phpecho 'Get Environment : ',getenv('os'),'<br>';echo 'Environment Path : ',getenv('path'),'<br>';echo '<hr>';echo 'Document Root : ',$_SERVER['DOCUMENT_ROOT'],'<br>';echo 'Http Host : ',$_SERVER['HTTP_HOST'],'<br>';echo 'Referer : ',$_SERVER['HTTP_REFERER'],'<br>';echo 'Method : ',$_SERVER['REQUEST_METHOD'],'<br>';echo 'User Agent : ',($_SERVER['HTTP_USER_AGENT']),'<br>';](/image.pl?url=https%3a%2f%2fimage.slidesharecdn.com%2fphpnotes-161223104036%2f75%2fPHP-HTML-CSS-Notes-118-2048.jpg&f=jpg&w=240)
![119echo 'Name of Script : ',$_SERVER['SCRIPT_NAME'],'<br>';echo 'Query String : ',$_SERVER['QUERY_STRING'],'<br>';echo 'Remote Ip Address : ',$_SERVER['REMOTE_ADDR'],'<br>';echo 'PHP Self : ',$_SERVER['PHP_SELF'],'<br>';echo 'Request URL : ',$_SERVER['REQUEST_URI'],'<br>';echo 'Script File Name : ',$_SERVER['SCRIPT_FILENAME'],'<br>';?>-----phpinfo.php<?phpecho phpinfo();?> Include_once and required _once : These both will include filevery first time and if already file has been included this will notinclude for the second time. Defference between include_once & include : Include andinclude _once will include the files. But if the path of the file is wronginclude and include_once will generate the wrong message and rest ofthe code will be excuted.Required and required_once : If location of the path is givenwrong this will through a wrong as well as path error and code getshalted or the execution will be stop.Ex : a.php<style>b{color:green;}</style><b>I am included</b><br><hr><?php](/image.pl?url=https%3a%2f%2fimage.slidesharecdn.com%2fphpnotes-161223104036%2f75%2fPHP-HTML-CSS-Notes-119-2048.jpg&f=jpg&w=240)




![124readfile($file);?>----down.phpmage down <a href="download.php"/>View Please</a>File Uploading :upload_tmp_dir(<path>) : default is set to c:xampptmp. Thetemporary location to which the file can be uploaded to the server.upload_max_filesize : (<128>) The max size for a single file whichcan be uploaded to the server -> max_file_uploads : 20.Functions in upload :copy of source destination : Copy the file from source location todestination folderis_upload_file(source path): Checks wheather file upload or notand return boolean.move_upload_file (<source path, destination>): Moves the filefrom source location to destination locationPredefined variables: - $_FILES is predefined super global filewhich will be loaded with theProperties in file upload :1. $_FILES[<file_field_name>]['name']: It returns the originalname of the uploaded file.2. $_FILES[<file_field_name>]['tmp_name']: It returns thetemporary path to the uploaded file.(It acts as the source path of the uploaded file in the program).3. $_FILES[<file_field_name>]['size']: It returns the size of theuploaded file in bytes.4. $_FILES[<file_field_name>]['type']: It gives the MIME(Multipurpose Internet Main Extension) type for the uploaded file.](/image.pl?url=https%3a%2f%2fimage.slidesharecdn.com%2fphpnotes-161223104036%2f75%2fPHP-HTML-CSS-Notes-124-2048.jpg&f=jpg&w=240)
![1255. $_FILES[<file_field_name>]['error']: It returns the error codeassociated with the file upload.If its value is configured to zero indicates no error.Ex : testupload.php<?phpif(isset($_POST['submit'])){if(isset($_FILES['photo'])){$src = $_FILES['photo']['tmp_name'];$desc ="pics/".getRandString(12).$_FILES['photo']['name'];if(move_uploaded_file($src,$desc)){echo 'Image saved successfully<br>';} else {echo 'Image not saved<br>';}}}echo '<hr>';function getRandString($size){$a =str_shuffle('abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890');return addslashes(substr($a,0,$size));}?>](/image.pl?url=https%3a%2f%2fimage.slidesharecdn.com%2fphpnotes-161223104036%2f75%2fPHP-HTML-CSS-Notes-125-2048.jpg&f=jpg&w=240)
![126-----test.php<form action='testupload.php' method='POST'enctype='multipart/form-data'/>Upload Photo : <input type='file' name='photo'/> <input type='submit'name='submit' value='Upload'/></form>COOKIES :Cookies are super global variables which can be stored at clientmachine.$_COOKIE: It is a predefined super global variable which can beused for reading cookie data.setcookie(<name>,<value>): It is a predefined function for creating,updating or deleting the cookie variable at server machine.cookie values are stored at the browser of client's machinecookies are not safe for storing the information.Every webbrowser is limited to a certain number of cookies to bestored at the client's machine(~20).Cookies information will be exchanged between the client and serverevery request and response through headers.If Cookie is once created can be accessed from the next request fromthe server to the client but not in the same page.setcookie(<name>,<value>,[<lifetime>],[<domain>],[<path>],[<secure protocol>])lifetime: Timestamp upto which cookie must be active.time()+24*60*60domain: news.abc.comgmail.com](/image.pl?url=https%3a%2f%2fimage.slidesharecdn.com%2fphpnotes-161223104036%2f75%2fPHP-HTML-CSS-Notes-126-2048.jpg&f=jpg&w=240)

![128SESSIONS :It is used for maintaining the state of the user between his login andlogout. Session information is stored at the server machine and isaccessable with the pages where session is started.$_SESSION is a predefined super global used for managing sessiondata.Configuration Settings:session.auto_start(OFF) : Controls whether the session must beautomatically started or not.session.name=PHPSESSID: The default name at which session id isstored at a client machine as cookie variable.session.use_cookie(ON*/OFF): Using the cookies for storing thesession id value.session.use_only_cookies: Using cookies only for storing the sessionid.session.use_trans_sid(0/1): Using a transferable session id throughURL.session.gc_maxlifetime(1440(24minutes)): The maximum time forwhich the session data can be maintaines when the user is idle beforesending to gc(garbage collector).Functions in SESSIONS :session_start(): Starts a new session for the user, if session alreadyaxists uses the already existing session.session_name[<optional_name>]: Gets or sets the name of thesession.session_id(): It returns the session id created for the user. A sessionid is a unique 32 character length alphanumeric value.session_regenerate_id : Changes the session id to new one for theuser.](/image.pl?url=https%3a%2f%2fimage.slidesharecdn.com%2fphpnotes-161223104036%2f75%2fPHP-HTML-CSS-Notes-128-2048.jpg&f=jpg&w=240)
![129session_unset: Erases the session data for the user.session_destroy: Session will be destroyed.Ex : session.php<?phpob_start();session_start();echo 'Session Name : ',session_name(),'<br>';echo 'Session Id : ',session_id(),'<br>';echo 'Session Name : ',session_name('Rajesh'),'<br>';echo 'Session Name : ',session_name(),'<br>';echo 'Session generate Id : ',session_regenerate_id(),'<br>';echo 'Generated Id : ',session_id(),'<br>';echo 'Life time : ',(ini_get('session.gc_maxlifetime')/60),' mins<br>';echo 'Session save Path : ',ini_get('session.save_path'),'<br>';echo 'Cookie Save Path : ',ini_get('session.cookie_path'),'<br>';$_SESSION['Name'] = 'Praveen';$_SESSION['Email'] = 'raj@gmail.com';print_r($_SESSION); echo '<hr>';print_r($_COOKIE);echo '<hr>';session_destroy();echo 'Session Id : ',session_id(),'<br>';print_r($_SESSION);unset($_SESSION['Name']);echo '<hr>';print_r($_SESSION);](/image.pl?url=https%3a%2f%2fimage.slidesharecdn.com%2fphpnotes-161223104036%2f75%2fPHP-HTML-CSS-Notes-129-2048.jpg&f=jpg&w=240)






![136Table Level Query : SHOW TABLES[FROM <db_name>]; CREATE TABLE <table_name> (<field_name><datatype>[<size>] <add_parementers> <field_info); ALTER TABLE <table_name> ADD <field_info>; CHANGE <field_name> <new_field_info>;ALTER TABLE <table_name> DROP <field_name>;RENAME <new_name>;(Renaming a Table) TRUNCATE <table_name>;This will empty the table. Removes the complete data ofthe table but the structure of table remains same in the database. DROP<table_name>; Removes the table data and its Structure;Data Level Query :Data manupulation Language:INSERT INTO <tbl_name> [(<field_list>)] VALUES[(<value_list>),(<value_list2),(value_list3)...]; UPDATE <tbl_name> SET <field_name> = <new_value>WHERE <cond>; DELETE FROM <tbl_name> WHERE <cond>;Data Retrival Query: SELECT (* or <field_list>) FROM <tbl_name> [WHERE<cond>] ORDER BY <field_name> ASC/DESC [GROUP BY<field_name> LIMIT <start_index>[,<length>]];Numerical Datatypes in MYSQL :1) Tiny Int : [2pow8 -1] 0-255 UNSIGNED[-128-127] SIGNED](/image.pl?url=https%3a%2f%2fimage.slidesharecdn.com%2fphpnotes-161223104036%2f75%2fPHP-HTML-CSS-Notes-136-2048.jpg&f=jpg&w=240)
![1372) Small Int : 2 bytes [2pow16-1] UNSIGNED-32767 TO -32767 SIGNED3) Mediun Int : 3 bytes [2pow24-1]UNSIGNED int [16777215]SIGNED int [-8388607]4) Int : 4 bytes [2pow31-1]SIGNED Int Range [2147483647]5) BigInt : 8 bytes [2pow64-1]0 - 1.84467440737096e+14 20digitsSize of integer will specify the total number of digitsAdditional Parameter SIGNED OR UNSIGNED default Value isSIGNED.6) float(<no of digits>,<precision>) :A small number with a floating Value .10POW38 0-24(falls in float)7) Double(no of digits>,<precision>) :A Large Number with a floating Decimal Point(25-5)8) Decimal() : A double stored as a string, allowing for a fixeddecimal point.9) Char() : A fixed Section from 0 to 255 character Long.10) varchar() : A variable section from 0-255 char long.Miscellaneous Types :ENUM() : ENUM stands for Enumeration, which means that eachcoloumn may have one of a specified possible Value.Text : String Content 65kb for this size is needed.medium text : 0 - 16777215 char (16mb) can be accomidated inmedium text..](/image.pl?url=https%3a%2f%2fimage.slidesharecdn.com%2fphpnotes-161223104036%2f75%2fPHP-HTML-CSS-Notes-137-2048.jpg&f=jpg&w=240)






![144WHERE p.c_id = c.Id AND p.b_id = b.Id ORDER BY AmountDESC;PHP by Default Support With Mysql library,,PHP communication with Mysql can be Splitted int some steps like1) Connecting to the Database2) Selecting to the Database3) Query the Database4) Fetching the Records or Getting the records From Query or QueryString.5) Close the Connection.1) Connecting to the Database Among them We haveA) Normal Connection B) Persistance ConnectionNormal Connection : Will be active for the Single Program, ANormal Connection can be Closed by Using mysql_close();mysql_connect('hostname','username','password');B) Persistance Connection : A Persistance Connection is aPermanent Connection Once establish it cannot be closed.mysql_pconnect('hostname','username','password');2) Selecting to the Databasemysql_select_db('dbname',[Optional Conn Handler]);Selects the Argumented data as current data...Error Handling in Database :a)mysql_error() : Returns the last Error Message Occured with thedata base server.](/image.pl?url=https%3a%2f%2fimage.slidesharecdn.com%2fphpnotes-161223104036%2f75%2fPHP-HTML-CSS-Notes-144-2048.jpg&f=jpg&w=240)


![147OOPSClass :It is a collection of properties (variables) and methods.Syntax :class <class_name>{//code}[abstract|final] class <class_name>{//code}Property (or) member : A property or member of a class is anidentifier which is used for storing data which can be accessiblethroughout the class.<public|protected| private>[static] <var> =<value>;Ex :public $x=10;protected $account_no=null;static public $conv_rate=0.87;Method :A method is an action for a class (or) a method is a function inside theclass](/image.pl?url=https%3a%2f%2fimage.slidesharecdn.com%2fphpnotes-161223104036%2f75%2fPHP-HTML-CSS-Notes-147-2048.jpg&f=jpg&w=240)
![148Syntax :[static][final|abstract][public*|protected|private] function<fun_name>([args]){//code}Ex :function getName(){return $this->name;}Object :It is an instance of a class.Object is used for accessing classproperties(public). Object can execute methods(public).Syntax :<object>=new <class_name>[args];It is the operator which is used for accessing class propertiesand excuting class methods using an objectEx :<?phpclass A{public $x=20;public function test(){](/image.pl?url=https%3a%2f%2fimage.slidesharecdn.com%2fphpnotes-161223104036%2f75%2fPHP-HTML-CSS-Notes-148-2048.jpg&f=jpg&w=240)













![162Other than IE :new XMLHttpRequest();Opening Request :if(window.ActiveXObject){document.write("IE");}else if(window.XMLHttpRequest){document.write("Other than IE");}else {document.write("No Ajax support");}Open :open(method,url,async,[user_name],[password]);Ex : ajax.open("Get","getuser.php?id=2",true);Sending the Request :Send :send(null|<parameters>)Ex:-send(ajax.send(null);Properties of AJAX :a) Ready State :0uninitialised(Ajax engine is created,connection is not established)1initialised(open method will be called,connection established)](/image.pl?url=https%3a%2f%2fimage.slidesharecdn.com%2fphpnotes-161223104036%2f75%2fPHP-HTML-CSS-Notes-162-2048.jpg&f=jpg&w=240)














![177b) -21c) 19d) NoneAns: b15) <script language="javascript">function x(){var s = "Quality 100%!{[!!";var pattern = /w/g;var output = s.match(pattern);document.write(output);}</script>a) %,!,{,[,!,!b) Q,u,a,l,i,t,y,1,0,0c) Quality 100d) ErrorAns: b16) <script type="text/javascript" language="javascript">var qpt= new Array();qpt[0] = "WebDevelopment";qpt[1]="ApplicationDevelopment"qpt[2]="Testing"qpt[3] = "Vempower Solutions";document.write(qpt[0,1,2,3]);</script>a) Errorb) Vempower Solutionc) WebDevelopmentd) WebDevelopmnet,ApplicationDevelopment,Testing,VempowerSolutions](/image.pl?url=https%3a%2f%2fimage.slidesharecdn.com%2fphpnotes-161223104036%2f75%2fPHP-HTML-CSS-Notes-177-2048.jpg&f=jpg&w=240)












![1902. when we use GET method requested data show in url butNot in POST method so POST method is good for send sensetiverequestQuestion : 7 How can we extract string "pcds.co.in " from astring "http://info@pcds.co.in using regular expression of PHP?Answer : 7preg_match("/^http://.+@(.+)$/","http://info@pcds.co.in",$matches);echo $matches[1];Question : 8 How can we create a database using PHP andMySQL?Answer : 8 We can create MySQL database with the use ofmysql_create_db("Database Name") .Question : 9 What are the differences between require andinclude?Answer : 9 Both include and require used to include a file but whenincluded file not found Include send Warning where as Require sendFatal Error .Question : 10 Can we use include ("xyz.PHP") two times in aPHP page "index.PHP"?Answer : 10 Yes we can use include("xyz.php") more than one timein any page. but it create a prob when xyz.php file contain somefuntions declaration then error will come for already declared functionin this file else not a prob like if you want to show same content twotime in page then must incude it two time not a prob.Question : 11 What are the different tables(Engine) present inMySQL, which one is default?Answer : 11 Following tables (Storage Engine) we can create.1. MyISAM(The default storage engine IN MYSQL Each MyISAMtable is stored on disk in three files. The files have names that beginwith the table name and have an extension to indicate the file type. An.frm file stores the table format. The data file has an .MYD (MYData)](/image.pl?url=https%3a%2f%2fimage.slidesharecdn.com%2fphpnotes-161223104036%2f75%2fPHP-HTML-CSS-Notes-190-2048.jpg&f=jpg&w=240)

![192Question : 14 Suppose your Zend engine supports the mode <? ?>Then how can u configure your PHP Zend engine to support<?PHP ?> mode ?Answer : 14 In php.ini file: set short_open_tag=on to make PHPsupport .Question : 15 Shopping cart online validation i.e. how can weconfigure Paypal, etc.?Answer : 15 Nothing more we have to do only redirect to the payPalurl aftersubmit all information needed by paypal like amount,adresss etc.Question : 16 What is meant by nl2br()?Answer : 16 Inserts HTML line breaks (<BR />) before all newlinesin a string.Question : 17 What is htaccess? Why do we use this and Where?Answer : 17 .htaccess files are configuration files of Apache Serverwhich providea way to make configuration changes on a per-directory basis. A file,containing one or more configuration directives, is placed in aparticulardocument directory, and the directives apply to that directory, and allsubdirectories thereof.Question : 18 How we get IP address of client, previous referencepage etc?Answer : 18 By using$_SERVER['REMOTE_ADDR'],$_SERVER['HTTP_REFERER']etc.Question : 19 What are the reasons for selecting lamp (Linux,apache, MySQL, PHP) instead of combination of other softwareprograms, servers and perating systems?Answer : 19 All of those are open source resource. Security of Linuxis very](/image.pl?url=https%3a%2f%2fimage.slidesharecdn.com%2fphpnotes-161223104036%2f75%2fPHP-HTML-CSS-Notes-192-2048.jpg&f=jpg&w=240)





![198date_default_timezone_set('Asia/Tokyo');// Now generate the timestamp for that particular timezone, on Jan 1st,2000$stamp = mktime(8, 0, 0, 1, 1, 2000);// Now set the timezone back to US/Easterndate_default_timezone_set('US/Eastern');// Output the date in a standard format (RFC1123), this will print:// Fri, 31 Dec 1999 18:00:00 ESTecho '<p>', date(DATE_RFC1123, $stamp) ,'</p>';?>Question : 33 What is meant by urlencode and urldocode?Answer : 33 URLencode returns a string in which all non-alphanumeric charactersexcept -_. have been replaced with a percent (%) sign followed bytwo hex digits and spaces encoded as plus (+) signs. It is encoded thesame way that the posted data from a WWW form is encoded, that isthe same way as inapplication/x-www-form-urlencoded media type.urldecode decodes any %##encoding in the given string.Question : 34 What is the difference between the functions unlinkand unset?Answer : 34 unlink() deletes the given file from the file system.unset() makes a variable undefined.Question : 35 How can we register the variables into a session?Answer : 35 $_SESSION['name'] = "sonia";Question : 36 How can we get the properties (size, type, width,height) of an image using PHP image functions?Answer : 36 To know the Image type use exif_imagetype () functionTo know the Image size use getimagesize () functionTo know the image width use imagesx () functionTo know the image height use imagesy() function.](/image.pl?url=https%3a%2f%2fimage.slidesharecdn.com%2fphpnotes-161223104036%2f75%2fPHP-HTML-CSS-Notes-198-2048.jpg&f=jpg&w=240)
![199Question : 37 How can we get the browser properties using PHP?Answer : 37 By using $_SERVER['HTTP_USER_AGENT']variable.Question : 38 What is the maximum size of a file that can beuploaded using PHP and how can we change this?Answer : 38 By default the maximum size is 2MB. and we canchange the followingsetup at php.ini upload_max_filesize = 2M.Question : 39 How can we increase the execution time of a PHPscript? Answer : 39 by changing the following setup at php.inimax_execution_time = 30; Maximum execution time of each script, in seconds.Question : 40 How can we take a backup of a MySQL table andhow can we restore it. ?Answer : 40 To backup: BACKUP TABLE tbl_name[,tbl_name…]TO'/path/to/backup/directory'. RESTORE TABLEtbl_name[,tbl_name…] FROM'/path/to/backup/directory'mysqldump: Dumping Table Structure andDataUtility to dump a database or a collection of database for backuporfor transferring the data to another SQL server (not necessarily aMySQLserver). The dump will contain SQL statements to create the tableand/orpopulate the table.Question : 41 How can we optimize or increase the speed of aMySQL selectquery?Answer : First of all instead of using select * from table1, use selectcolumn1, column2, column3.. from table1](/image.pl?url=https%3a%2f%2fimage.slidesharecdn.com%2fphpnotes-161223104036%2f75%2fPHP-HTML-CSS-Notes-199-2048.jpg&f=jpg&w=240)



![203Answer : 54 You can maintain two separate language file for each ofthelanguage. all the labels are putted in both language files as variablesand assign those variables in the PHP source. on runtime choose therequired language option.Question : 55 What are the difference between abstract class andinterface?Answer : 55 Abstract class: abstract classes are the class where oneor moremethods are abstract but not necessarily all method has to be abstract.Abstract methods are the methods, which are declare in its class butnotdefine. The definition of those methods must be in its extendingclass.Interface: Interfaces are one type of class where all the methodsareabstract. That means all the methods only declared but not defined.Allthe methods must be define by its implemented class.Question : 56 How can we send mail using JavaScript?Answer : 56 JavaScript does not have any networking capabilities asit isdesigned to work on client site. As a result we can not send mailsusingJavaScript. But we can call the client side mail protocol mailtovia JavaScript to prompt for an email to send. this requires the clientto approve it.Question : 57 How can we repair a MySQL table?Answer : 57 The syntex for repairing a MySQL table isREPAIR TABLENAME, [TABLENAME, ], [Quick],[Extended]This command will repair the table specified if the quick is given theMySQL will do a repair of only the index tree if the extended is givenit will create index row by row.Question : 58 What are the advantages of stored procedures,triggers, indexes?](/image.pl?url=https%3a%2f%2fimage.slidesharecdn.com%2fphpnotes-161223104036%2f75%2fPHP-HTML-CSS-Notes-203-2048.jpg&f=jpg&w=240)


![206The data file has a '.MYD' (MYData) extension.The index file has a '.MYI' (MYIndex) extension.Question : 64 What is maximum size of a database in MySQL?Answer : 64 If the operating system or filesystem places a limit onthe numberof files in a directory, MySQL is bound by that constraint.Theefficiency of the operating system in handling large numbers of filesin a directory can place a practical limit on the number of tables in adatabase. If the time required to open a file in the directory increasessignificantly as the number of files increases, databaseperformance can be adversely affected. The amount of available diskspace limits the number of tables.MySQL 3.22 had a 4GB (4gigabyte) limit on table size. With the MyISAM storage engine inMySQL 3.23, the maximum table size was increased to65536 terabytes (2567 – 1 bytes). With this larger allowed tablesize,the maximum effective table size for MySQL databases is usuallydetermined by operating system constraints on file sizes, not byMySQL internal limits.The InnoDB storage engine maintains InnoDBtables within a tablespace that can be created from several files. Thisallows a table to exceed the maximum individual file size. Thetablespace can include raw disk partitions, which allows extremelylarge tables. The maximum tablespace size is 64TB. The followingtable lists some examples of operating system file-sizelimits. This isonly a rough guide and is not intended to be definitive.For the mostup-to-date information, be sure to check the documentationspecific to your operating system.Operating System File-size.LimitLinux 2.2-Intel 32-bit 2GB (LFS: 4GB) Linux 2.4+ (using ext3filesystem) 4TBSolaris 9/10 16TBNetWare w/NSS filesystem 8TBWin32 w/ FAT/FAT32 2GB/4GBWin32 w/ NTFS 2TB (possibly larger)MacOS X w/ HFS+ 2TB.Question : 65 Give the syntax of Grant and Revoke commands?Answer : 65 The generic syntax for grant is as followingGRANT [rights] on [database/s] TO [username@hostname]](/image.pl?url=https%3a%2f%2fimage.slidesharecdn.com%2fphpnotes-161223104036%2f75%2fPHP-HTML-CSS-Notes-206-2048.jpg&f=jpg&w=240)
![207IDENTIFIED BY [password] now rights can bea) All privilegesb) combination of create, drop, select, insert, update and delete etc.Wecan grant rights on all databse by using *.* or some specificdatabase by database.* or a specific table by database.table_nameusername@hotsname can be either username@localhost,username@hostnameand username@%where hostname is any valid hostname and % represents any name,the *.*any conditionpassword is simply the password of userThe generic syntax for revokeis as followingREVOKE [rights] on [database/s] FROM [username@hostname] nowrights can be as explained abovea) All privilegesb) combination of create, drop, select, insert, update and delete etc.username@hotsname can be either username@localhost,username@hostnameand username@%where hostname is any valid hostname and % represents any name,the *.*any conditionQuestion : 66 Explain Normalization concept?Answer : 66 The normalization process involves getting our data toconform tothree progressive normal forms, and a higher level of normalizationcannot be achieved until the previous levels have been achieved (thereare actually five normal forms, but the last two are mainly academicandwill not be discussed).First Normal FormThe First Normal Form (or1NF) involves removal of redundant datafrom horizontal rows. We want to ensure that there is no duplicationofdata in a given row, and that every column stores the least amount ofinformation possible (making the field atomic).Second Normal](/image.pl?url=https%3a%2f%2fimage.slidesharecdn.com%2fphpnotes-161223104036%2f75%2fPHP-HTML-CSS-Notes-207-2048.jpg&f=jpg&w=240)


![210Answer : 72 Primary Key: A column in a table whose valuesuniquely identify therows in the table. A primary key value cannot be NULL.Unique Key: Unique Keys are used to uniquely identify each row inthe table. There can be one and only one row for each unique keyvalue. So NULL can be a unique key.There can be only one primarykey for a table but there can be more than one unique for a table.Question : 73 what is garbage collection? default time ? refreshtime?Answer : 73 Garbage Collection is an automated part of PHP , If theGarbage Collection process runs, it then analyzes any files in the /tmpfor any session files that have not been accessed in a certain amountof time and physically deletes them. Garbage Collection process onlyruns in the default session save directory, which is /tmp. If you opt tosave your sessions in a different directory, the Garbage Collectionprocess will ignore it. the Garbage Collection process does notdifferentiate between which sessions belong to whom when run. Thisis especially important note on shared web servers. If the process isrun, it deletes ALL files that have not been accessed in the directory.There are 3 PHP.ini variables, which deal with the garbage collector:PHP ini value name default session.gc_maxlifetime 1440 seconds or24 minutes session.gc_probability 1 session.gc_divisor 100.Question : 74 What are the advantages/disadvantages of MySQLand PHP? Answer : 74 Both of them are open source software (sofree of cost), supportcross platform. php is faster then ASP and JSP.Question : 75 What is the difference between GROUP BY andORDER BY in Sql? Answer : 75 ORDER BY[col1],[col2],…,[coln]; Tels DBMS according to what columns itshould sort the result. If two rows will hawe the same value in col1it will try to sort them according to col2 and so on.GROUP BY[col1],[col2],…,[coln]; Tels DBMS to group results with same valueofcolumn col1. You can use COUNT(col1), SUM(col1), AVG(col1)](/image.pl?url=https%3a%2f%2fimage.slidesharecdn.com%2fphpnotes-161223104036%2f75%2fPHP-HTML-CSS-Notes-210-2048.jpg&f=jpg&w=240)

![212Answer : 81by using spl_autoload_register('autoloader::funtion');Like belowclass autoloader{public static function moduleautoloader($class){$path = $_SERVER['DOCUMENT_ROOT'] ."/modules/{$class}.php";if (is_readable($path)) require $path;}public static function daoautoloader($class){$path = $_SERVER['DOCUMENT_ROOT'] ."/dataobjects/{$class}.php";if (is_readable($path)) require $path;}public static function includesautoloader($class){$path = $_SERVER['DOCUMENT_ROOT'] ."/includes/{$class}.php";if (is_readable($path)) require $path;}}spl_autoload_register('autoloader::includesautoloader');spl_autoload_register('autoloader::daoautoloader');spl_autoload_register('autoloader::moduleautoloader');Question : 82 How many types of Inheritances used in PHP andhow we achieve it.](/image.pl?url=https%3a%2f%2fimage.slidesharecdn.com%2fphpnotes-161223104036%2f75%2fPHP-HTML-CSS-Notes-212-2048.jpg&f=jpg&w=240)


![215feature has been DEPRECATED as of PHP 5.3.0 and REMOVED asof PHP 6.0.0. Relying on this feature is highly discouraged.Question : 92 what is cross site scripting? SQL injection?Answer : 92 Cross-site scripting (XSS) is a type of computer securityvulnerability typically found in web applications which allow codeinjection by malicious web users into the web pages viewed by otherusers. Examples of such code include HTML code and client-sidescripts. SQL injection is a code injection technique that exploits asecurity vulnerability occurring in the database layer of anapplication. The vulnerability is present when user input is eitherincorrectly filtered for string literal escape characters embedded inSQL statements or user input is not strongly typed and therebyunexpectedly executed.Question : 93 what is URL rewriting?Answer : 93 Using URL rewriting we can convert dynamic URl tostatic URL Static URLs are known to be better than Dynamic URLsbecause of a number of reasons 1. Static URLs typically Rank betterin Search Engines. 2. Search Engines are known to index the contentof dynamic pages a lot slower compared to static pages. 3. StaticURLs are always more friendlier looking to the End Users. along withthis we can use URL rewriting in adding variables [cookies] to theURL to handle the sessions.Question : 94 what is the major php security hole? how to avoid?Answer : 94 1. Never include, require, or otherwise open a file with afilename based on user input, without thoroughly checking it first.2. Be careful with eval() Placing user-inputted values into the eval()function can be extremely dangerous. You essentially give themalicious user the ability to execute any command he or she wishes!3. Be careful when using register_globals = ON It was originallydesigned to make programming in PHP easier (and that it did), butmisuse of it often led to security holes4. Never run unescaped queries5. For protected areas, use sessions or validate the login every time.](/image.pl?url=https%3a%2f%2fimage.slidesharecdn.com%2fphpnotes-161223104036%2f75%2fPHP-HTML-CSS-Notes-215-2048.jpg&f=jpg&w=240)

![217supporting FTP, FTPS, HTTP, HTTPS, SCP, SFTP, TFTP, TELNET,DICT, LDAP, LDAPS and FILE. curl supports SSL certificates,HTTP POST, HTTP PUT, FTP uploading, HTTP form based upload,proxies, cookies, user+password authentication (Basic, Digest,NTLM, Negotiate), file transfer resume, proxy tunneling and abusload of other useful tricks. CURL allows you to connect andcommunicate to many different types of servers with many differenttypes of protocols. libcurl currently supports the http, https, ftp,gopher, telnet, dict, file, and ldap protocols. libcurl also supportsHTTPS certificates, HTTP POST, HTTP PUT, FTP uploading. HTTPform based upload, proxies, cookies, and user+passwordauthentication.Question : 99 what is PDO ?Answer : 99The PDO ( PHP Data Objects ) extension defines a lightweight,consistent interface for accessing databases in PHP. if you are usingthe PDO API, you could switch the database server you used, fromsay PgSQL to MySQL, and only need to make minor changes to yourPHP code. While PDO has its advantages, such as a clean, simple,portable API but its main disadvantage is that it doesn't allow you touse all of the advanced features that are available in the latest versionsof MySQL server. For example, PDO does not allow you to useMySQL's support for Multiple Statements.Just need to use below code for connect mysql using PDOtry {$dbh = new PDO("mysql:host=$hostname;dbname=databasename",$username, $password);$sql = "SELECT * FROM employee";foreach ($dbh->query($sql) as $row){print $row['employee_name'] .' - '. $row['employee_age'] ;}}catch(PDOException $e){](/image.pl?url=https%3a%2f%2fimage.slidesharecdn.com%2fphpnotes-161223104036%2f75%2fPHP-HTML-CSS-Notes-217-2048.jpg&f=jpg&w=240)


The document provides an overview of HTML (Hypertext Markup Language) including:1) HTML is a markup language used to describe web pages using tags to structure content like headings, paragraphs, lists, links, images and tables. 2) Various HTML tags are described like <h1>-<h6> for headings, <p> for paragraphs, <b> for bold, <i> for italic, and <a> for links. 3) Additional HTML concepts covered include internal and external CSS, meta tags, images, tables, frames, iframes and cascading style sheets (CSS) for styling content.
















![17input[type='text']{color:deeppink;}</style></head><body>Name : <input type='text’ name='name' class='x'><br>username : <input type='text' name='uname'><br></body></html>7.Pseudo selector :Ex : pseudo.html<html><head><title>Pseudo Selector</title><style>p:first-letter{font-size:30pt;color:deeppink;font-family:arial black;}p:first-line{color:orange;}](/image.pl?url=https%3a%2f%2fimage.slidesharecdn.com%2fphpnotes-161223104036%2f75%2fPHP-HTML-CSS-Notes-17-2048.jpg&f=jpg&w=240)








![26JavaScript 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 usingscript tag. JavaScript can be saved with .js as its extension.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 is outputstatement to the browser.Ex: first.html<html><head>](/image.pl?url=https%3a%2f%2fimage.slidesharecdn.com%2fphpnotes-161223104036%2f75%2fPHP-HTML-CSS-Notes-26-2048.jpg&f=jpg&w=240)









![36 While, do-while , for-loop will not print string indexes inJavaScript so to print string indexes we can go withSyntax: - for (var name in Array name) For is key word in JavaScript which will print the string index The Array object is used to store multiple values in a singlevariable. An array is a special variable, which can hold more than onevalue, 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 integermyCars[0]="Saab"; // argument to control array's size)myCars[1]="Volvo";myCars[2]="BMW";2: var myCars=new Array("Saab","Volvo","BMW"); // condensedarray3: var myCars=["Saab","Volvo","BMW"]; // literal arrayEx : Array.html<script>var a = new Array(10,20,30,40);document.write('The Array is : '+a+'<br>');document.write('Length of Array : '+a.length+'<br>');document.write('Index at 2 : '+a[2]+'<br>');a[2] = a[2]*2;document.write('The Array is : '+a+'<br>');a[4] = 'New Value';](/image.pl?url=https%3a%2f%2fimage.slidesharecdn.com%2fphpnotes-161223104036%2f75%2fPHP-HTML-CSS-Notes-36-2048.jpg&f=jpg&w=240)
![37document.write('The Array is : '+a+'<br>');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('<hr>Single string Index : '+b['Name']+'<hr>');document.write('The Array is : '+b+'<br>');for(i=0;i<b.length;i++){document.write('Index at : '+i+' = '+b[i]+'<br>');}document.write('<hr>');for(c in b){document.write(c+' = '+b[c]+'<br>');}document.write('<hr>');var d = [10,20,30];document.write('The Array in d is : '+d+'<br>');document.write('The Array in d is : '+d.length+'<br>');document.write('<hr>');](/image.pl?url=https%3a%2f%2fimage.slidesharecdn.com%2fphpnotes-161223104036%2f75%2fPHP-HTML-CSS-Notes-37-2048.jpg&f=jpg&w=240)
![38var e = {'Name':'Rajesh','Age':30,10:20,'Status':'Active'};document.write('The Array in d is : '+e+'<br>');for(i=0;i<e.length;i++){document.write('Index at : '+i+' = '+e[i]+'<br>');}for(c in e){document.write(c+' = '+e[c]+'<br>');}</script>Double dimensional array:An array can have more than one array is called double dimensionalarray.Ex : douledimensionarray.html<html><head><script>var a =[[1,'Ajay',[45,62,49,72,55,84]],[2,'Rajesh',[48,62,94,72,38,62]],[3,'Suresh',[48,63,82,97,45,28]]];//document.write(a[1][1]);document.write('Name is : '+a[2][1]);document.write("<table border='1' align='center' width='60%' >");document.write("<tr><th colspan='9'>Student Marks Memo Report</th> ");](/image.pl?url=https%3a%2f%2fimage.slidesharecdn.com%2fphpnotes-161223104036%2f75%2fPHP-HTML-CSS-Notes-38-2048.jpg&f=jpg&w=240)
![39document.write("<tr><td rowspan='2'>Roll No</td> <tdrowspan='2'>Name</td><td colspan='6'align='center'>Subjects</td><td rowspan='2'>Pass/Fail</td></tr>");document.write("<tr><td>English</td><td>Hindi</td><td>Telugu</td> <td>Maths</td><td>Science</td><td>Social</td></tr>");document.write("<tr><td>"+a[0][0]+"</td></tr>");</script></head><body><tr><td><script>document.write(a[1][0]);</script></td><td><script>document.write(a[1][1]);</script></td></tr></table></body></html>Array built-in Functions :Join : Join is the pre-defined key-word in the JavaScript .which willconvert the given array into the separator passed default separator iscoma (,).Concat : concat is joining more than array in single array is calledconcat.Reverse : reverse in JavaScript the array last being is first. First islast without (descending order) the original array will also getaffected. If we use reverse function.Sort : sort is nothing but given the order is ascending order .Unshift : unshift will add the value at the starting of the array. Thevariable use for unshift will holds the length of the array and theoriginal array would get affected.](/image.pl?url=https%3a%2f%2fimage.slidesharecdn.com%2fphpnotes-161223104036%2f75%2fPHP-HTML-CSS-Notes-39-2048.jpg&f=jpg&w=240)







![47r('<hr><h2><u>Slice Function([begin, stop]) </u></h2>');r('Slice(4) = '+str.slice(4));r('Slice(4,8) = '+str.slice(4,8));r('Slice(-9) = '+str.slice(-9));r('Slice(-9,8) = '+str.slice(-9,8));r('Slice(-9,-3) = '+str.slice(-9,-3));r('<hr><h2><u>Substring Function([From, to]) </u></h2>');r('substring(4) = '+str.substring(4));r('substring(4,8) = '+str.substring(4,8));r('substring(4,2) = '+str.substring(4,2));//r('substring(-9) = '+str.substring(-9));r('<hr><h2><u>substr([start, length]) </u></h2>');r('substr(4) = '+str.substr(4));r('substr(5,8) = '+str.substr(5,8));r('substr(-9) = '+str.substr(-9));r('substr(-9,2) = '+str.substr(-9,1));r('CharAt(0) = '+str.charAt(1));r('charCodeAt(1) = '+str.charCodeAt(1)); //ascill Value of Indexmob = 'Z123456789';r('charCodeAt = '+mob.charCodeAt(0));r('Indexof = '+str.indexOf('T'));//-1r('lastIndexof = '+str.lastIndexOf('t'));r('indexOf = '+str.indexOf('t',9));r('Search = '+str.search('z'));//-1](/image.pl?url=https%3a%2f%2fimage.slidesharecdn.com%2fphpnotes-161223104036%2f75%2fPHP-HTML-CSS-Notes-47-2048.jpg&f=jpg&w=240)




![52</form></body>GetElementByTagName :This particular function will match tag name and excute the functionwhich we are passing as a tag nameEx : getElementsByTagName.html<script>function dochange(){var a = document.getElementsByTagName('div');for(i=0;i<a.length;i++){a[i].style.width = '400px';a[i].style.background = '#ddd';a[i].style.border = '4px dotted green';}}</script><body onmouseover='dochange();'><h1>Welcome to My Web Page</h1><p>This is my First Page</p><p>This is my First Page</p><p>This is my First Page</p><p>This is my First Page</p><div>What is Social Hub</div></body>](/image.pl?url=https%3a%2f%2fimage.slidesharecdn.com%2fphpnotes-161223104036%2f75%2fPHP-HTML-CSS-Notes-52-2048.jpg&f=jpg&w=240)
![53GetElementByName :This particular function will match element name and that part of thefunction will get excutes.Ex : getElementsByName.html<script>function dochange(){var a = document.getElementsByName('x');for(i=0;i<a.length;i++){a[i].style.width = '400px';a[i].style.background = '#ddd';a[i].style.border = '4px dotted green';}}</script><body onmouseover='dochange();'><h1>Welcome to My Web Page</h1><p>This is my First Page</p><p>This is my First Page</p><p>This is my First Page</p><p>This is my First Page</p><div>What is Social Hub</div></body>Note 1 : As ids are unique we have singular matching so we cangetElementById as singular.](/image.pl?url=https%3a%2f%2fimage.slidesharecdn.com%2fphpnotes-161223104036%2f75%2fPHP-HTML-CSS-Notes-53-2048.jpg&f=jpg&w=240)













![67echo 'The Value of $x = ',$x,'<br>';function test(){//global $x;echo 'The Value of $x inside Function = ',$x,'<br>';echo '$GLOBALS["x"] = ',$GLOBALS['x'],'<br>';}test();?>Super global array variable : ‘$ global’ is the super global arrayvariable. This is the pre-defined keyword. In php we have mainlysome of the super global variables. This can be used with theirkeywords.i) $_EVN : This is used for getting the information of your operatingsystem ($_ENV (PATH))ii) $_SERVER : This will give you the information about yourserver(apache information)iii) $_GET : It is used for form processing through get method (or)query stringiv) $_POST : This is used for form processing through post methodin secure mannerv) $_REQUEST : It will send the form through both get and post andcookievi)$_COOKIE : This is used to get the information about the browserwho is using the web(computer)vii)$_SESSION : It is used to get the information of the user inbetween login and logout details are store at server machine.](/image.pl?url=https%3a%2f%2fimage.slidesharecdn.com%2fphpnotes-161223104036%2f75%2fPHP-HTML-CSS-Notes-67-2048.jpg&f=jpg&w=240)

![69echo 'My name is : ',$name,'<br>';echo '<h1 align="center">Arthamatic Operator</h1>';echo 'The value of 2+3 : ',2+3,'<br>';echo 'The Value of 2-3 : ',2-3,'<br>';echo 'The Value of 2/3 : ',2/3,'<br>';echo 'The Value of 2*3 : ',2*3,'<br>';echo 'The Value of 2%3 : ',2%3,'<br>';echo '<h1 align="center">Increment & Decrement [INC/DEC]</h1>';echo '<h2>POST & PRE increment</h2>';$x = 10;echo 'The Value of $x = ',$x,'<br>';echo 'The Value of $x++ = ',$x++,'<br>';echo 'The Value of $x = ',$x,'<br>';echo 'The Value of ++$x = ',++$x,'<br>';echo 'The Value of $x = ',$x,'<br>';echo '<h2>POST & PRE Decrement</h2>';echo 'The Value of $x-- = ',$x--,'<br>';echo 'The Value of $x = ',$x,'<br>';echo 'The Value of --$x = ',--$x,'<br>';echo 'The Value of $x = ',$x,'<br>';echo '<h1 align="center">Comparision Operator</h1>';](/image.pl?url=https%3a%2f%2fimage.slidesharecdn.com%2fphpnotes-161223104036%2f75%2fPHP-HTML-CSS-Notes-69-2048.jpg&f=jpg&w=240)








![78iii) Mixed arrayDeclaring an array in php can be done by two types array as the function array as a square bracketi) Numerical array :A numeric array stores each array element with a numeric index.There are two methods to create a numeric array. In the following example the index are automatically assigned(the index starts at 0):$cars=array("Saab","Volvo","BMW","Toyota"); In the following example we assign the index manually:$cars[0]="Saab";$cars[1]="Volvo";$cars[2]="BMW";$cars[3]="Toyota";Ex :<?php$cars[0]="Saab";$cars[1]="Volvo";$cars[2]="BMW";$cars[3]="Toyota";echo $cars[0] . " and " . $cars[1] . " are Swedish cars.";?>ii) Associative array :An associative array, each ID key is associated with a value.](/image.pl?url=https%3a%2f%2fimage.slidesharecdn.com%2fphpnotes-161223104036%2f75%2fPHP-HTML-CSS-Notes-78-2048.jpg&f=jpg&w=240)
![79When storing data about specific named values, a numerical array isnot always the best way to do it.With associative arrays we can use the values as keys and assignvalues to them.Example 1In this example we use an array to assign ages to the differentpersons:$ages = array("Peter"=>32, "Quagmire"=>30, "Joe"=>34);Example 2This example is the same as example 1, but shows a different way ofcreating the array:$ages['Peter'] = "32";$ages['Quagmire'] = "30";$ages['Joe'] = "34";The ID keys can be used in a script:<?php$ages['Peter'] = "32";$ages['Quagmire'] = "30";$ages['Joe'] = "34";echo "Peter is " . $ages['Peter'] . " years old.";?>The code above will output:Peter is 32 years old.iii) Mixed array :Mixed array is nothing but combination of numerical & associativearray is known as mixed array.](/image.pl?url=https%3a%2f%2fimage.slidesharecdn.com%2fphpnotes-161223104036%2f75%2fPHP-HTML-CSS-Notes-79-2048.jpg&f=jpg&w=240)









![89f)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 isforeach (arrayName as arr[value])){echo arr [value];}Another syntax isforeach (arrayname as key=>value){echo key’-‘value (or) echo “key-value”;}Ex : foreach.php<?php$a = array("Name"=>"Rajesh","Age"=>30);/*foreach(arrayname as value){echo arr[value];}*/foreach($a as $v){echo $v,'<br>';}echo '<hr>';/*foreach(arrayname as key=>value){echo key,' - ',value;}*/foreach($a as $k=>$v){](/image.pl?url=https%3a%2f%2fimage.slidesharecdn.com%2fphpnotes-161223104036%2f75%2fPHP-HTML-CSS-Notes-89-2048.jpg&f=jpg&w=240)













![103echo 'Do we have Value with some :',var_dump(in_array('Male',$a)),'<br>';$a =array('Name'=>'Rajesh','Age'=>30,'Status'=>'Active','Email'=>'Raj@gmail.com','Gender'=>'Male');r(array_keys($a),'Array Keys Calling');r(array_values($a),'Array Value Calling');$str = 'Hey i am from India & my name is Praveen';$b = explode(" ",$str);//print_r($b);echo '<br>';echo 'The Length of your total Words = ',count($b),'<br><hr>';for($i=0;$i<count($b);$i++){echo 'The index at ',$i,' = ',$b[$i],'<br>';}$a =array('raj@gmail.com','amith@gmail.com','raju@gmail.com','suresh@gmail.com','raj@gmail.com','amith@gmail.com','raju@gmail.com','suresh@gmail.com');print_r($a);$b = implode(',',$a);<br><br>To : <input type='text' name='name' value='<?php echo $b;?>'size='60'/><hr><?php$a = array('born','child','teen','father','dead');r($a,'Normal Array');](/image.pl?url=https%3a%2f%2fimage.slidesharecdn.com%2fphpnotes-161223104036%2f75%2fPHP-HTML-CSS-Notes-103-2048.jpg&f=jpg&w=240)












![116Super Globals :Difference between GET and POST :GET POST1.GET data transfers through URL. POST data is sendthrough request headers2.GET is insecure POST is secure3.File cannot be transfered using GET Files can betransfered4.Limited data can be send based on length We can send hugedata(8MB) which can be scaledof URL supported by browser(2KB). up by usingPOST_MAX_SIZE5.It is fast It is not as fast as GET.6.$_GET is used for accessing $_POST is used for accessingthe GET parameters the POST parametersGET Ex :-----get.php<?phpif(isset($_GET['submit'])){echo 'Name : ',$_GET['fname'],'<br>';echo 'Email Address : ',$_GET['email'],'<br>';$gend = ($_GET['gender'] == 'm')?'Male':'Female';echo 'Gender : ',$gend,'<br>';}](/image.pl?url=https%3a%2f%2fimage.slidesharecdn.com%2fphpnotes-161223104036%2f75%2fPHP-HTML-CSS-Notes-116-2048.jpg&f=jpg&w=240)
![117echo '<hr>';echo urldecode($_SERVER['QUERY_STRING']);echo '<hr><br>';?>-----get.html<form method='GET' action='get.php'>Name : <input type='text' name='fname' value=''><br>E-Mail : <input type='text' name='email' value=''><br>Gender : <input type='radio' name='gender' value='m'> Male <inputtype='radio' name='gender' value='f'> Female<br><input type='submit' name='submit' value='Register !'></form>POST Ex :-----post.php<?phpif(isset($_POST['submit'])){echo 'Name : ',$_POST['fname'],'<br>';echo 'Email Address : ',$_POST['email'],'<br>';$gend = ($_POST['gender']=='m')?'Male':'Female';echo 'Gender : ',$gend,'<br>';$a = $_POST['course'];echo $a,'<br><hr>';print_r($a);}echo '<hr>';echo 'The query string : ',$_SERVER['QUERY_STRING'],'<br>';](/image.pl?url=https%3a%2f%2fimage.slidesharecdn.com%2fphpnotes-161223104036%2f75%2fPHP-HTML-CSS-Notes-117-2048.jpg&f=jpg&w=240)
![118?>-----post.html<form method='POST' action='post.php'/>Name : <input type='text' name='fname' value=''/><br>E-Mail : <input type='text' name='email' value=''/><br>Gender : <input type='radio' name='gender' value='m'/> Male <inputtype='radio' name='gender' value='f'/> Female <br>Hobbies : <br><input type='checkbox' name='course[]' value='c'/> C-Language <br><input type='checkbox' name='course[]' value='p'/> PHP <br><input type='checkbox' name='course[]' value='j'/> Java <br><input type='submit' name='submit' value='Register'/></form>Server Variables :-----servervariables.php<?phpecho 'Get Environment : ',getenv('os'),'<br>';echo 'Environment Path : ',getenv('path'),'<br>';echo '<hr>';echo 'Document Root : ',$_SERVER['DOCUMENT_ROOT'],'<br>';echo 'Http Host : ',$_SERVER['HTTP_HOST'],'<br>';echo 'Referer : ',$_SERVER['HTTP_REFERER'],'<br>';echo 'Method : ',$_SERVER['REQUEST_METHOD'],'<br>';echo 'User Agent : ',($_SERVER['HTTP_USER_AGENT']),'<br>';](/image.pl?url=https%3a%2f%2fimage.slidesharecdn.com%2fphpnotes-161223104036%2f75%2fPHP-HTML-CSS-Notes-118-2048.jpg&f=jpg&w=240)
![119echo 'Name of Script : ',$_SERVER['SCRIPT_NAME'],'<br>';echo 'Query String : ',$_SERVER['QUERY_STRING'],'<br>';echo 'Remote Ip Address : ',$_SERVER['REMOTE_ADDR'],'<br>';echo 'PHP Self : ',$_SERVER['PHP_SELF'],'<br>';echo 'Request URL : ',$_SERVER['REQUEST_URI'],'<br>';echo 'Script File Name : ',$_SERVER['SCRIPT_FILENAME'],'<br>';?>-----phpinfo.php<?phpecho phpinfo();?> Include_once and required _once : These both will include filevery first time and if already file has been included this will notinclude for the second time. Defference between include_once & include : Include andinclude _once will include the files. But if the path of the file is wronginclude and include_once will generate the wrong message and rest ofthe code will be excuted.Required and required_once : If location of the path is givenwrong this will through a wrong as well as path error and code getshalted or the execution will be stop.Ex : a.php<style>b{color:green;}</style><b>I am included</b><br><hr><?php](/image.pl?url=https%3a%2f%2fimage.slidesharecdn.com%2fphpnotes-161223104036%2f75%2fPHP-HTML-CSS-Notes-119-2048.jpg&f=jpg&w=240)




![124readfile($file);?>----down.phpmage down <a href="download.php"/>View Please</a>File Uploading :upload_tmp_dir(<path>) : default is set to c:xampptmp. Thetemporary location to which the file can be uploaded to the server.upload_max_filesize : (<128>) The max size for a single file whichcan be uploaded to the server -> max_file_uploads : 20.Functions in upload :copy of source destination : Copy the file from source location todestination folderis_upload_file(source path): Checks wheather file upload or notand return boolean.move_upload_file (<source path, destination>): Moves the filefrom source location to destination locationPredefined variables: - $_FILES is predefined super global filewhich will be loaded with theProperties in file upload :1. $_FILES[<file_field_name>]['name']: It returns the originalname of the uploaded file.2. $_FILES[<file_field_name>]['tmp_name']: It returns thetemporary path to the uploaded file.(It acts as the source path of the uploaded file in the program).3. $_FILES[<file_field_name>]['size']: It returns the size of theuploaded file in bytes.4. $_FILES[<file_field_name>]['type']: It gives the MIME(Multipurpose Internet Main Extension) type for the uploaded file.](/image.pl?url=https%3a%2f%2fimage.slidesharecdn.com%2fphpnotes-161223104036%2f75%2fPHP-HTML-CSS-Notes-124-2048.jpg&f=jpg&w=240)
![1255. $_FILES[<file_field_name>]['error']: It returns the error codeassociated with the file upload.If its value is configured to zero indicates no error.Ex : testupload.php<?phpif(isset($_POST['submit'])){if(isset($_FILES['photo'])){$src = $_FILES['photo']['tmp_name'];$desc ="pics/".getRandString(12).$_FILES['photo']['name'];if(move_uploaded_file($src,$desc)){echo 'Image saved successfully<br>';} else {echo 'Image not saved<br>';}}}echo '<hr>';function getRandString($size){$a =str_shuffle('abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890');return addslashes(substr($a,0,$size));}?>](/image.pl?url=https%3a%2f%2fimage.slidesharecdn.com%2fphpnotes-161223104036%2f75%2fPHP-HTML-CSS-Notes-125-2048.jpg&f=jpg&w=240)
![126-----test.php<form action='testupload.php' method='POST'enctype='multipart/form-data'/>Upload Photo : <input type='file' name='photo'/> <input type='submit'name='submit' value='Upload'/></form>COOKIES :Cookies are super global variables which can be stored at clientmachine.$_COOKIE: It is a predefined super global variable which can beused for reading cookie data.setcookie(<name>,<value>): It is a predefined function for creating,updating or deleting the cookie variable at server machine.cookie values are stored at the browser of client's machinecookies are not safe for storing the information.Every webbrowser is limited to a certain number of cookies to bestored at the client's machine(~20).Cookies information will be exchanged between the client and serverevery request and response through headers.If Cookie is once created can be accessed from the next request fromthe server to the client but not in the same page.setcookie(<name>,<value>,[<lifetime>],[<domain>],[<path>],[<secure protocol>])lifetime: Timestamp upto which cookie must be active.time()+24*60*60domain: news.abc.comgmail.com](/image.pl?url=https%3a%2f%2fimage.slidesharecdn.com%2fphpnotes-161223104036%2f75%2fPHP-HTML-CSS-Notes-126-2048.jpg&f=jpg&w=240)

![128SESSIONS :It is used for maintaining the state of the user between his login andlogout. Session information is stored at the server machine and isaccessable with the pages where session is started.$_SESSION is a predefined super global used for managing sessiondata.Configuration Settings:session.auto_start(OFF) : Controls whether the session must beautomatically started or not.session.name=PHPSESSID: The default name at which session id isstored at a client machine as cookie variable.session.use_cookie(ON*/OFF): Using the cookies for storing thesession id value.session.use_only_cookies: Using cookies only for storing the sessionid.session.use_trans_sid(0/1): Using a transferable session id throughURL.session.gc_maxlifetime(1440(24minutes)): The maximum time forwhich the session data can be maintaines when the user is idle beforesending to gc(garbage collector).Functions in SESSIONS :session_start(): Starts a new session for the user, if session alreadyaxists uses the already existing session.session_name[<optional_name>]: Gets or sets the name of thesession.session_id(): It returns the session id created for the user. A sessionid is a unique 32 character length alphanumeric value.session_regenerate_id : Changes the session id to new one for theuser.](/image.pl?url=https%3a%2f%2fimage.slidesharecdn.com%2fphpnotes-161223104036%2f75%2fPHP-HTML-CSS-Notes-128-2048.jpg&f=jpg&w=240)
![129session_unset: Erases the session data for the user.session_destroy: Session will be destroyed.Ex : session.php<?phpob_start();session_start();echo 'Session Name : ',session_name(),'<br>';echo 'Session Id : ',session_id(),'<br>';echo 'Session Name : ',session_name('Rajesh'),'<br>';echo 'Session Name : ',session_name(),'<br>';echo 'Session generate Id : ',session_regenerate_id(),'<br>';echo 'Generated Id : ',session_id(),'<br>';echo 'Life time : ',(ini_get('session.gc_maxlifetime')/60),' mins<br>';echo 'Session save Path : ',ini_get('session.save_path'),'<br>';echo 'Cookie Save Path : ',ini_get('session.cookie_path'),'<br>';$_SESSION['Name'] = 'Praveen';$_SESSION['Email'] = 'raj@gmail.com';print_r($_SESSION); echo '<hr>';print_r($_COOKIE);echo '<hr>';session_destroy();echo 'Session Id : ',session_id(),'<br>';print_r($_SESSION);unset($_SESSION['Name']);echo '<hr>';print_r($_SESSION);](/image.pl?url=https%3a%2f%2fimage.slidesharecdn.com%2fphpnotes-161223104036%2f75%2fPHP-HTML-CSS-Notes-129-2048.jpg&f=jpg&w=240)






![136Table Level Query : SHOW TABLES[FROM <db_name>]; CREATE TABLE <table_name> (<field_name><datatype>[<size>] <add_parementers> <field_info); ALTER TABLE <table_name> ADD <field_info>; CHANGE <field_name> <new_field_info>;ALTER TABLE <table_name> DROP <field_name>;RENAME <new_name>;(Renaming a Table) TRUNCATE <table_name>;This will empty the table. Removes the complete data ofthe table but the structure of table remains same in the database. DROP<table_name>; Removes the table data and its Structure;Data Level Query :Data manupulation Language:INSERT INTO <tbl_name> [(<field_list>)] VALUES[(<value_list>),(<value_list2),(value_list3)...]; UPDATE <tbl_name> SET <field_name> = <new_value>WHERE <cond>; DELETE FROM <tbl_name> WHERE <cond>;Data Retrival Query: SELECT (* or <field_list>) FROM <tbl_name> [WHERE<cond>] ORDER BY <field_name> ASC/DESC [GROUP BY<field_name> LIMIT <start_index>[,<length>]];Numerical Datatypes in MYSQL :1) Tiny Int : [2pow8 -1] 0-255 UNSIGNED[-128-127] SIGNED](/image.pl?url=https%3a%2f%2fimage.slidesharecdn.com%2fphpnotes-161223104036%2f75%2fPHP-HTML-CSS-Notes-136-2048.jpg&f=jpg&w=240)
![1372) Small Int : 2 bytes [2pow16-1] UNSIGNED-32767 TO -32767 SIGNED3) Mediun Int : 3 bytes [2pow24-1]UNSIGNED int [16777215]SIGNED int [-8388607]4) Int : 4 bytes [2pow31-1]SIGNED Int Range [2147483647]5) BigInt : 8 bytes [2pow64-1]0 - 1.84467440737096e+14 20digitsSize of integer will specify the total number of digitsAdditional Parameter SIGNED OR UNSIGNED default Value isSIGNED.6) float(<no of digits>,<precision>) :A small number with a floating Value .10POW38 0-24(falls in float)7) Double(no of digits>,<precision>) :A Large Number with a floating Decimal Point(25-5)8) Decimal() : A double stored as a string, allowing for a fixeddecimal point.9) Char() : A fixed Section from 0 to 255 character Long.10) varchar() : A variable section from 0-255 char long.Miscellaneous Types :ENUM() : ENUM stands for Enumeration, which means that eachcoloumn may have one of a specified possible Value.Text : String Content 65kb for this size is needed.medium text : 0 - 16777215 char (16mb) can be accomidated inmedium text..](/image.pl?url=https%3a%2f%2fimage.slidesharecdn.com%2fphpnotes-161223104036%2f75%2fPHP-HTML-CSS-Notes-137-2048.jpg&f=jpg&w=240)






![144WHERE p.c_id = c.Id AND p.b_id = b.Id ORDER BY AmountDESC;PHP by Default Support With Mysql library,,PHP communication with Mysql can be Splitted int some steps like1) Connecting to the Database2) Selecting to the Database3) Query the Database4) Fetching the Records or Getting the records From Query or QueryString.5) Close the Connection.1) Connecting to the Database Among them We haveA) Normal Connection B) Persistance ConnectionNormal Connection : Will be active for the Single Program, ANormal Connection can be Closed by Using mysql_close();mysql_connect('hostname','username','password');B) Persistance Connection : A Persistance Connection is aPermanent Connection Once establish it cannot be closed.mysql_pconnect('hostname','username','password');2) Selecting to the Databasemysql_select_db('dbname',[Optional Conn Handler]);Selects the Argumented data as current data...Error Handling in Database :a)mysql_error() : Returns the last Error Message Occured with thedata base server.](/image.pl?url=https%3a%2f%2fimage.slidesharecdn.com%2fphpnotes-161223104036%2f75%2fPHP-HTML-CSS-Notes-144-2048.jpg&f=jpg&w=240)


![147OOPSClass :It is a collection of properties (variables) and methods.Syntax :class <class_name>{//code}[abstract|final] class <class_name>{//code}Property (or) member : A property or member of a class is anidentifier which is used for storing data which can be accessiblethroughout the class.<public|protected| private>[static] <var> =<value>;Ex :public $x=10;protected $account_no=null;static public $conv_rate=0.87;Method :A method is an action for a class (or) a method is a function inside theclass](/image.pl?url=https%3a%2f%2fimage.slidesharecdn.com%2fphpnotes-161223104036%2f75%2fPHP-HTML-CSS-Notes-147-2048.jpg&f=jpg&w=240)
![148Syntax :[static][final|abstract][public*|protected|private] function<fun_name>([args]){//code}Ex :function getName(){return $this->name;}Object :It is an instance of a class.Object is used for accessing classproperties(public). Object can execute methods(public).Syntax :<object>=new <class_name>[args];It is the operator which is used for accessing class propertiesand excuting class methods using an objectEx :<?phpclass A{public $x=20;public function test(){](/image.pl?url=https%3a%2f%2fimage.slidesharecdn.com%2fphpnotes-161223104036%2f75%2fPHP-HTML-CSS-Notes-148-2048.jpg&f=jpg&w=240)













![162Other than IE :new XMLHttpRequest();Opening Request :if(window.ActiveXObject){document.write("IE");}else if(window.XMLHttpRequest){document.write("Other than IE");}else {document.write("No Ajax support");}Open :open(method,url,async,[user_name],[password]);Ex : ajax.open("Get","getuser.php?id=2",true);Sending the Request :Send :send(null|<parameters>)Ex:-send(ajax.send(null);Properties of AJAX :a) Ready State :0uninitialised(Ajax engine is created,connection is not established)1initialised(open method will be called,connection established)](/image.pl?url=https%3a%2f%2fimage.slidesharecdn.com%2fphpnotes-161223104036%2f75%2fPHP-HTML-CSS-Notes-162-2048.jpg&f=jpg&w=240)














![177b) -21c) 19d) NoneAns: b15) <script language="javascript">function x(){var s = "Quality 100%!{[!!";var pattern = /w/g;var output = s.match(pattern);document.write(output);}</script>a) %,!,{,[,!,!b) Q,u,a,l,i,t,y,1,0,0c) Quality 100d) ErrorAns: b16) <script type="text/javascript" language="javascript">var qpt= new Array();qpt[0] = "WebDevelopment";qpt[1]="ApplicationDevelopment"qpt[2]="Testing"qpt[3] = "Vempower Solutions";document.write(qpt[0,1,2,3]);</script>a) Errorb) Vempower Solutionc) WebDevelopmentd) WebDevelopmnet,ApplicationDevelopment,Testing,VempowerSolutions](/image.pl?url=https%3a%2f%2fimage.slidesharecdn.com%2fphpnotes-161223104036%2f75%2fPHP-HTML-CSS-Notes-177-2048.jpg&f=jpg&w=240)












![1902. when we use GET method requested data show in url butNot in POST method so POST method is good for send sensetiverequestQuestion : 7 How can we extract string "pcds.co.in " from astring "http://info@pcds.co.in using regular expression of PHP?Answer : 7preg_match("/^http://.+@(.+)$/","http://info@pcds.co.in",$matches);echo $matches[1];Question : 8 How can we create a database using PHP andMySQL?Answer : 8 We can create MySQL database with the use ofmysql_create_db("Database Name") .Question : 9 What are the differences between require andinclude?Answer : 9 Both include and require used to include a file but whenincluded file not found Include send Warning where as Require sendFatal Error .Question : 10 Can we use include ("xyz.PHP") two times in aPHP page "index.PHP"?Answer : 10 Yes we can use include("xyz.php") more than one timein any page. but it create a prob when xyz.php file contain somefuntions declaration then error will come for already declared functionin this file else not a prob like if you want to show same content twotime in page then must incude it two time not a prob.Question : 11 What are the different tables(Engine) present inMySQL, which one is default?Answer : 11 Following tables (Storage Engine) we can create.1. MyISAM(The default storage engine IN MYSQL Each MyISAMtable is stored on disk in three files. The files have names that beginwith the table name and have an extension to indicate the file type. An.frm file stores the table format. The data file has an .MYD (MYData)](/image.pl?url=https%3a%2f%2fimage.slidesharecdn.com%2fphpnotes-161223104036%2f75%2fPHP-HTML-CSS-Notes-190-2048.jpg&f=jpg&w=240)

![192Question : 14 Suppose your Zend engine supports the mode <? ?>Then how can u configure your PHP Zend engine to support<?PHP ?> mode ?Answer : 14 In php.ini file: set short_open_tag=on to make PHPsupport .Question : 15 Shopping cart online validation i.e. how can weconfigure Paypal, etc.?Answer : 15 Nothing more we have to do only redirect to the payPalurl aftersubmit all information needed by paypal like amount,adresss etc.Question : 16 What is meant by nl2br()?Answer : 16 Inserts HTML line breaks (<BR />) before all newlinesin a string.Question : 17 What is htaccess? Why do we use this and Where?Answer : 17 .htaccess files are configuration files of Apache Serverwhich providea way to make configuration changes on a per-directory basis. A file,containing one or more configuration directives, is placed in aparticulardocument directory, and the directives apply to that directory, and allsubdirectories thereof.Question : 18 How we get IP address of client, previous referencepage etc?Answer : 18 By using$_SERVER['REMOTE_ADDR'],$_SERVER['HTTP_REFERER']etc.Question : 19 What are the reasons for selecting lamp (Linux,apache, MySQL, PHP) instead of combination of other softwareprograms, servers and perating systems?Answer : 19 All of those are open source resource. Security of Linuxis very](/image.pl?url=https%3a%2f%2fimage.slidesharecdn.com%2fphpnotes-161223104036%2f75%2fPHP-HTML-CSS-Notes-192-2048.jpg&f=jpg&w=240)





![198date_default_timezone_set('Asia/Tokyo');// Now generate the timestamp for that particular timezone, on Jan 1st,2000$stamp = mktime(8, 0, 0, 1, 1, 2000);// Now set the timezone back to US/Easterndate_default_timezone_set('US/Eastern');// Output the date in a standard format (RFC1123), this will print:// Fri, 31 Dec 1999 18:00:00 ESTecho '<p>', date(DATE_RFC1123, $stamp) ,'</p>';?>Question : 33 What is meant by urlencode and urldocode?Answer : 33 URLencode returns a string in which all non-alphanumeric charactersexcept -_. have been replaced with a percent (%) sign followed bytwo hex digits and spaces encoded as plus (+) signs. It is encoded thesame way that the posted data from a WWW form is encoded, that isthe same way as inapplication/x-www-form-urlencoded media type.urldecode decodes any %##encoding in the given string.Question : 34 What is the difference between the functions unlinkand unset?Answer : 34 unlink() deletes the given file from the file system.unset() makes a variable undefined.Question : 35 How can we register the variables into a session?Answer : 35 $_SESSION['name'] = "sonia";Question : 36 How can we get the properties (size, type, width,height) of an image using PHP image functions?Answer : 36 To know the Image type use exif_imagetype () functionTo know the Image size use getimagesize () functionTo know the image width use imagesx () functionTo know the image height use imagesy() function.](/image.pl?url=https%3a%2f%2fimage.slidesharecdn.com%2fphpnotes-161223104036%2f75%2fPHP-HTML-CSS-Notes-198-2048.jpg&f=jpg&w=240)
![199Question : 37 How can we get the browser properties using PHP?Answer : 37 By using $_SERVER['HTTP_USER_AGENT']variable.Question : 38 What is the maximum size of a file that can beuploaded using PHP and how can we change this?Answer : 38 By default the maximum size is 2MB. and we canchange the followingsetup at php.ini upload_max_filesize = 2M.Question : 39 How can we increase the execution time of a PHPscript? Answer : 39 by changing the following setup at php.inimax_execution_time = 30; Maximum execution time of each script, in seconds.Question : 40 How can we take a backup of a MySQL table andhow can we restore it. ?Answer : 40 To backup: BACKUP TABLE tbl_name[,tbl_name…]TO'/path/to/backup/directory'. RESTORE TABLEtbl_name[,tbl_name…] FROM'/path/to/backup/directory'mysqldump: Dumping Table Structure andDataUtility to dump a database or a collection of database for backuporfor transferring the data to another SQL server (not necessarily aMySQLserver). The dump will contain SQL statements to create the tableand/orpopulate the table.Question : 41 How can we optimize or increase the speed of aMySQL selectquery?Answer : First of all instead of using select * from table1, use selectcolumn1, column2, column3.. from table1](/image.pl?url=https%3a%2f%2fimage.slidesharecdn.com%2fphpnotes-161223104036%2f75%2fPHP-HTML-CSS-Notes-199-2048.jpg&f=jpg&w=240)



![203Answer : 54 You can maintain two separate language file for each ofthelanguage. all the labels are putted in both language files as variablesand assign those variables in the PHP source. on runtime choose therequired language option.Question : 55 What are the difference between abstract class andinterface?Answer : 55 Abstract class: abstract classes are the class where oneor moremethods are abstract but not necessarily all method has to be abstract.Abstract methods are the methods, which are declare in its class butnotdefine. The definition of those methods must be in its extendingclass.Interface: Interfaces are one type of class where all the methodsareabstract. That means all the methods only declared but not defined.Allthe methods must be define by its implemented class.Question : 56 How can we send mail using JavaScript?Answer : 56 JavaScript does not have any networking capabilities asit isdesigned to work on client site. As a result we can not send mailsusingJavaScript. But we can call the client side mail protocol mailtovia JavaScript to prompt for an email to send. this requires the clientto approve it.Question : 57 How can we repair a MySQL table?Answer : 57 The syntex for repairing a MySQL table isREPAIR TABLENAME, [TABLENAME, ], [Quick],[Extended]This command will repair the table specified if the quick is given theMySQL will do a repair of only the index tree if the extended is givenit will create index row by row.Question : 58 What are the advantages of stored procedures,triggers, indexes?](/image.pl?url=https%3a%2f%2fimage.slidesharecdn.com%2fphpnotes-161223104036%2f75%2fPHP-HTML-CSS-Notes-203-2048.jpg&f=jpg&w=240)


![206The data file has a '.MYD' (MYData) extension.The index file has a '.MYI' (MYIndex) extension.Question : 64 What is maximum size of a database in MySQL?Answer : 64 If the operating system or filesystem places a limit onthe numberof files in a directory, MySQL is bound by that constraint.Theefficiency of the operating system in handling large numbers of filesin a directory can place a practical limit on the number of tables in adatabase. If the time required to open a file in the directory increasessignificantly as the number of files increases, databaseperformance can be adversely affected. The amount of available diskspace limits the number of tables.MySQL 3.22 had a 4GB (4gigabyte) limit on table size. With the MyISAM storage engine inMySQL 3.23, the maximum table size was increased to65536 terabytes (2567 – 1 bytes). With this larger allowed tablesize,the maximum effective table size for MySQL databases is usuallydetermined by operating system constraints on file sizes, not byMySQL internal limits.The InnoDB storage engine maintains InnoDBtables within a tablespace that can be created from several files. Thisallows a table to exceed the maximum individual file size. Thetablespace can include raw disk partitions, which allows extremelylarge tables. The maximum tablespace size is 64TB. The followingtable lists some examples of operating system file-sizelimits. This isonly a rough guide and is not intended to be definitive.For the mostup-to-date information, be sure to check the documentationspecific to your operating system.Operating System File-size.LimitLinux 2.2-Intel 32-bit 2GB (LFS: 4GB) Linux 2.4+ (using ext3filesystem) 4TBSolaris 9/10 16TBNetWare w/NSS filesystem 8TBWin32 w/ FAT/FAT32 2GB/4GBWin32 w/ NTFS 2TB (possibly larger)MacOS X w/ HFS+ 2TB.Question : 65 Give the syntax of Grant and Revoke commands?Answer : 65 The generic syntax for grant is as followingGRANT [rights] on [database/s] TO [username@hostname]](/image.pl?url=https%3a%2f%2fimage.slidesharecdn.com%2fphpnotes-161223104036%2f75%2fPHP-HTML-CSS-Notes-206-2048.jpg&f=jpg&w=240)
![207IDENTIFIED BY [password] now rights can bea) All privilegesb) combination of create, drop, select, insert, update and delete etc.Wecan grant rights on all databse by using *.* or some specificdatabase by database.* or a specific table by database.table_nameusername@hotsname can be either username@localhost,username@hostnameand username@%where hostname is any valid hostname and % represents any name,the *.*any conditionpassword is simply the password of userThe generic syntax for revokeis as followingREVOKE [rights] on [database/s] FROM [username@hostname] nowrights can be as explained abovea) All privilegesb) combination of create, drop, select, insert, update and delete etc.username@hotsname can be either username@localhost,username@hostnameand username@%where hostname is any valid hostname and % represents any name,the *.*any conditionQuestion : 66 Explain Normalization concept?Answer : 66 The normalization process involves getting our data toconform tothree progressive normal forms, and a higher level of normalizationcannot be achieved until the previous levels have been achieved (thereare actually five normal forms, but the last two are mainly academicandwill not be discussed).First Normal FormThe First Normal Form (or1NF) involves removal of redundant datafrom horizontal rows. We want to ensure that there is no duplicationofdata in a given row, and that every column stores the least amount ofinformation possible (making the field atomic).Second Normal](/image.pl?url=https%3a%2f%2fimage.slidesharecdn.com%2fphpnotes-161223104036%2f75%2fPHP-HTML-CSS-Notes-207-2048.jpg&f=jpg&w=240)


![210Answer : 72 Primary Key: A column in a table whose valuesuniquely identify therows in the table. A primary key value cannot be NULL.Unique Key: Unique Keys are used to uniquely identify each row inthe table. There can be one and only one row for each unique keyvalue. So NULL can be a unique key.There can be only one primarykey for a table but there can be more than one unique for a table.Question : 73 what is garbage collection? default time ? refreshtime?Answer : 73 Garbage Collection is an automated part of PHP , If theGarbage Collection process runs, it then analyzes any files in the /tmpfor any session files that have not been accessed in a certain amountof time and physically deletes them. Garbage Collection process onlyruns in the default session save directory, which is /tmp. If you opt tosave your sessions in a different directory, the Garbage Collectionprocess will ignore it. the Garbage Collection process does notdifferentiate between which sessions belong to whom when run. Thisis especially important note on shared web servers. If the process isrun, it deletes ALL files that have not been accessed in the directory.There are 3 PHP.ini variables, which deal with the garbage collector:PHP ini value name default session.gc_maxlifetime 1440 seconds or24 minutes session.gc_probability 1 session.gc_divisor 100.Question : 74 What are the advantages/disadvantages of MySQLand PHP? Answer : 74 Both of them are open source software (sofree of cost), supportcross platform. php is faster then ASP and JSP.Question : 75 What is the difference between GROUP BY andORDER BY in Sql? Answer : 75 ORDER BY[col1],[col2],…,[coln]; Tels DBMS according to what columns itshould sort the result. If two rows will hawe the same value in col1it will try to sort them according to col2 and so on.GROUP BY[col1],[col2],…,[coln]; Tels DBMS to group results with same valueofcolumn col1. You can use COUNT(col1), SUM(col1), AVG(col1)](/image.pl?url=https%3a%2f%2fimage.slidesharecdn.com%2fphpnotes-161223104036%2f75%2fPHP-HTML-CSS-Notes-210-2048.jpg&f=jpg&w=240)

![212Answer : 81by using spl_autoload_register('autoloader::funtion');Like belowclass autoloader{public static function moduleautoloader($class){$path = $_SERVER['DOCUMENT_ROOT'] ."/modules/{$class}.php";if (is_readable($path)) require $path;}public static function daoautoloader($class){$path = $_SERVER['DOCUMENT_ROOT'] ."/dataobjects/{$class}.php";if (is_readable($path)) require $path;}public static function includesautoloader($class){$path = $_SERVER['DOCUMENT_ROOT'] ."/includes/{$class}.php";if (is_readable($path)) require $path;}}spl_autoload_register('autoloader::includesautoloader');spl_autoload_register('autoloader::daoautoloader');spl_autoload_register('autoloader::moduleautoloader');Question : 82 How many types of Inheritances used in PHP andhow we achieve it.](/image.pl?url=https%3a%2f%2fimage.slidesharecdn.com%2fphpnotes-161223104036%2f75%2fPHP-HTML-CSS-Notes-212-2048.jpg&f=jpg&w=240)


![215feature has been DEPRECATED as of PHP 5.3.0 and REMOVED asof PHP 6.0.0. Relying on this feature is highly discouraged.Question : 92 what is cross site scripting? SQL injection?Answer : 92 Cross-site scripting (XSS) is a type of computer securityvulnerability typically found in web applications which allow codeinjection by malicious web users into the web pages viewed by otherusers. Examples of such code include HTML code and client-sidescripts. SQL injection is a code injection technique that exploits asecurity vulnerability occurring in the database layer of anapplication. The vulnerability is present when user input is eitherincorrectly filtered for string literal escape characters embedded inSQL statements or user input is not strongly typed and therebyunexpectedly executed.Question : 93 what is URL rewriting?Answer : 93 Using URL rewriting we can convert dynamic URl tostatic URL Static URLs are known to be better than Dynamic URLsbecause of a number of reasons 1. Static URLs typically Rank betterin Search Engines. 2. Search Engines are known to index the contentof dynamic pages a lot slower compared to static pages. 3. StaticURLs are always more friendlier looking to the End Users. along withthis we can use URL rewriting in adding variables [cookies] to theURL to handle the sessions.Question : 94 what is the major php security hole? how to avoid?Answer : 94 1. Never include, require, or otherwise open a file with afilename based on user input, without thoroughly checking it first.2. Be careful with eval() Placing user-inputted values into the eval()function can be extremely dangerous. You essentially give themalicious user the ability to execute any command he or she wishes!3. Be careful when using register_globals = ON It was originallydesigned to make programming in PHP easier (and that it did), butmisuse of it often led to security holes4. Never run unescaped queries5. For protected areas, use sessions or validate the login every time.](/image.pl?url=https%3a%2f%2fimage.slidesharecdn.com%2fphpnotes-161223104036%2f75%2fPHP-HTML-CSS-Notes-215-2048.jpg&f=jpg&w=240)

![217supporting FTP, FTPS, HTTP, HTTPS, SCP, SFTP, TFTP, TELNET,DICT, LDAP, LDAPS and FILE. curl supports SSL certificates,HTTP POST, HTTP PUT, FTP uploading, HTTP form based upload,proxies, cookies, user+password authentication (Basic, Digest,NTLM, Negotiate), file transfer resume, proxy tunneling and abusload of other useful tricks. CURL allows you to connect andcommunicate to many different types of servers with many differenttypes of protocols. libcurl currently supports the http, https, ftp,gopher, telnet, dict, file, and ldap protocols. libcurl also supportsHTTPS certificates, HTTP POST, HTTP PUT, FTP uploading. HTTPform based upload, proxies, cookies, and user+passwordauthentication.Question : 99 what is PDO ?Answer : 99The PDO ( PHP Data Objects ) extension defines a lightweight,consistent interface for accessing databases in PHP. if you are usingthe PDO API, you could switch the database server you used, fromsay PgSQL to MySQL, and only need to make minor changes to yourPHP code. While PDO has its advantages, such as a clean, simple,portable API but its main disadvantage is that it doesn't allow you touse all of the advanced features that are available in the latest versionsof MySQL server. For example, PDO does not allow you to useMySQL's support for Multiple Statements.Just need to use below code for connect mysql using PDOtry {$dbh = new PDO("mysql:host=$hostname;dbname=databasename",$username, $password);$sql = "SELECT * FROM employee";foreach ($dbh->query($sql) as $row){print $row['employee_name'] .' - '. $row['employee_age'] ;}}catch(PDOException $e){](/image.pl?url=https%3a%2f%2fimage.slidesharecdn.com%2fphpnotes-161223104036%2f75%2fPHP-HTML-CSS-Notes-217-2048.jpg&f=jpg&w=240)
