Presentation is loading. Please wait.

Presentation is loading. Please wait.

Open Source Programming

Similar presentations


Presentation on theme: "Open Source Programming"— Presentation transcript:

1 Open Source Programming
11/11/2018

2 Open Source Programming
Unit – I Introduction Open source Programming PHP, Apache, MySQL, Postgress, SQL and Perl- Overview of PHP – Variables, operators, Constants, control structures arrays, Functions, classes – Handling files. Open Source Programming 11/11/2018

3 Open Source Programming
What is Open source By allowing the open exchange of information, programmers from all over the world contribute to make a truly powerful and efficient piece of software without royalties or fees. Open Source Programming 11/11/2018

4 Open Source Programming
Why OSP ROCKS? They are free. They are cross-platform and “technology-neutral.” They must not restrict other software. They embrace diversity. Open Source Programming 11/11/2018

5 Open Source Programming
OSP Software - OS Linux — operating system kernel based on Unix GNU Project — a sufficient body of free software OpenBSD — operating system derived from Unix FreeBSD — operating system derived from Unix OpenSolaris — Unix Operating System from Sun Microsystems Symbian — real-time mobile operating system Open Source Programming 11/11/2018

6 Open Source Programming
OSP Software - Server Apache — HTTP web server Tomcat web server — web container Mediawiki — wiki server software Alfresco, TYPO3 — content management system RenovatioCMS — content management system Joomla — content management system Drupal — content management system Open Source Programming 11/11/2018

7 Open Source Programming
OSP Software WordPress — blog software MongoDB — document-oriented, non-relational database Eclipse — software development environment comprising an integrated development environment (IDE) Moodle — course management system or virtual learning environment openSIS — open source Student Information System Open Source Programming 11/11/2018

8 Open Source Programming
OSP Software osCommerce — ecommerce PeaZip — File archiver Mozilla Firefox — web browser Mozilla Thunderbird — client OpenOffice.org — office suite Stockfish — chess engine series, one of the strongest chess programs 7-Zip – File Archiever Open Source Programming 11/11/2018

9 Open Source Programming
OSP Software (Others) PHP — Hypertext Preprocessor PERL & Python — Interpreted Dynamic Language MySQL — Data Base Open Source Programming 11/11/2018

10 Open Source Programming
Intro to AMP Package AMP is an acronym formed from the initials of Apache, MySQL and PHP or Python or Perl. Apache: It acts as Web server. Its main job is to parse any file requested by a browser and display the correct results according to the code within that file. PHP: PHP is a server-side scripting language that allows your Web site to be truly dynamic. MySQL: It enables PHP and Apache to work together to access and display data in a readable format to a browser. Open Source Programming 11/11/2018

11 Open Source Programming
AMP as Restaurant Apache – This is the Chef. Whatever people ask for, prepares it without complaint. She is quick, flexible, and able to prepare a multitude of different types of foods. Open Source Programming 11/11/2018

12 Open Source Programming
AMP as Restaurant PHP – This is the Waiter, gets requests from the patron and carries them back to the kitchen with specific instructions about how the meal should be prepared. Open Source Programming 11/11/2018

13 Open Source Programming
AMP as Restaurant MySQL – This is Stockroom of ingredients. Open Source Programming 11/11/2018

14 Open Source Programming
Apache Introduction Appache is a Web server Responds to client requests by providing resources URI (Uniform Resource Identifier) Web server and client communicate with platform-independent Hypertext Transfer Protocol (HTTP) Open Source Programming 11/11/2018

15 Open Source Programming
HTTP request types Request methods get post Retrieve and send client form data to Web server Post data to a server-side form handler Open Source Programming 11/11/2018

16 Open Source Programming
System Architecture Multi-tier application (n-tier application) Information tier (data or bottom tier) Maintains data for the application Stores data in a relational database management system (RDBMS) Middle tier Implements business logic and presentation logic Control interactions between application clients and application data Client tier (top tier) Application’s user interface Users interact directly with the application through the client tier Open Source Programming 11/11/2018

17 Overview of Php PHP Hypertext Preprocessor.
Other Names : Personal Home Page, Professional Home Page PHP is a server side scripting language. Capable of generating the HTML pages HTML generates the web page with the static text and images. However the need evolved for dynamic web based application, mostly involving database usage. 11/11/2018

18 Open Source Programming
Features of PHP There are no. of server side scripting available like ASP, SSJS, JSP….. PHP involves simplicity in scripting (..generally using the database) platform independence. PHP is primarily designed for web applications well optimized for the response times needed for web applications Is an open source. Open Source Programming 11/11/2018

19 Open Source Programming
How it works? WEB SERVER HTTP Request (url) <HTML> <?php echo ‘hello’; ?> </HTML> Gets Page <HTML> <B>Hello</B> </HTML> Interprets the PHP code CLIENT Server response Browser creates the web page 11/11/2018 Open Source Programming

20 Open Source Programming
PHP with HTML PHP programs are written using a text editor, such as Notepad or WordPad, just like HTML pages. PHP pages, for the most part, end in a .php extension. This extension signifies to the server that it needs to parse the PHP code before sending the resulting HTML code to the viewer’s Web browser. Open Source Programming 11/11/2018

21 Open Source Programming
PHP with HTML What makes PHP so different is that it not only allows HTML pages to be created. It is invisible to your Web site visitors. The only thing they see the resulting HTML output. This gives you more security for your PHP code and more flexibility in writing it. HTML can also be written inside the PHP section of your page. PHP can also be written as a standalone program, with no HTML Open Source Programming 11/11/2018

22 Open Source Programming
PHP Syntax PHP is denoted in the page with opening and closing tags as follows: <?php //php code; ?> Open Source Programming 11/11/2018

23 Open Source Programming
PHP Programs Code Result <HTML> <HEAD> <TITLE> My First PHP Program </TITLE> <h1> </HEAD> <BODY> <?php echo “I’m a PHP Program.”; ?> </BODY> </HTML> Open Source Programming 11/11/2018

24 Open Source Programming
PHP Programs Code Result <?php $name=“VIT UNIVERSITY”; echo ‘My name is ‘,$name; ?> Open Source Programming 11/11/2018

25 Open Source Programming
Data Type Four basic data types: Integer Double String Boolean More data types Array Object PHP is an untyped language variables type can change on the fly. Open Source Programming 11/11/2018

26 Open Source Programming
Constants ..values that never changes. Constants are defined in PHP by using the define( ) function. For e.g. define(“NCST”, “National Centre for Software Technology”) By convention, constant names are usually in UPPERCASE. defined() function says whether the constant exists or not. Open Source Programming 11/11/2018

27 Constants contd.. <?php define(‘NAME’,‘Phil’); define(‘AGE’,23);
echo NAME; echo ’ is ‘; echo AGE; // Phil is 23 ?> 11/11/2018

28 Open Source Programming
Variables The variables in PHP are declared by appending the $ sign to the variable name. For e.g $company = “NCST”; $sum = 10.0; Variable’s data type is changed by the value that is assigned to the variable. Type casting allows to change the data type explicitly. Open Source Programming 11/11/2018

29 Open Source Programming
Variables Rules for Naming Variables: In PHP, unlike some other programming languages, there is no restriction on the size of a variable name. Variable names should identified by dollar ($) symbol. Variable names can begin with an underscore. Variable names cannot begin with a numeric character. Variable names must be relevant and self-explanatory. Open Source Programming 11/11/2018

30 Open Source Programming
Variables Valid Examples Non Valid Examples $prod_desc $9OctSales $Intvar Sales123 $_Salesamt $*asgs Open Source Programming 11/11/2018

31 Open Source Programming
Variables (cont) $MyStrVal = "This is an example of a string value"; $MyIntVal = ; // An integer value $MyBoolval = True; // A Boolean value can either be True or False $MyFloatVal= // A float value $MyArrVal[0] = "My"; //A array containing three elements $MyArrVal[1] = "First"; $MyArrVal[2] = "Array"; Open Source Programming 11/11/2018

32 Integers Integers can be specified in decimal (base 10), hexadecimal (base 16), octal (base 8) or binary (base 2) notation, optionally preceded by a sign (- or +). Binary integer literals are available since PHP To use octal notation, precede the number with a 0 (zero). To use hexadecimal notation precede the number with0x. To use binary notation precede the number with 0b. 11/11/2018

33 Open Source Programming
Settype In PHP, Variable type can be changed by Settype Settype Syntax: Settype(Variablename, “newDataType”); E.g. $pi = 3.14 //float Settype($pi,”string”); //now string – “3.14” Settype($pi,”integer”);// now integer - 3 Open Source Programming 11/11/2018

34 Open Source Programming
Settype & Gettype In PHP, Variable type and can know by Gettype. Syntax: Gettype(Variablename); E.g. $pi = 3.14; //float print gettype($pi); Print “---$pi <br>”; Settype($pi,”string”); Settype($pi,”integer”); Open Source Programming 11/11/2018

35 Type Casting To change type through casting you indicate the name of a data type, in parentheses, in front of the variable you are copying. Eg: $newvar=(integer) $originalvar It creates a copy of the $originalvar variable, with a specific type (int) and a new name $newvar. The $originalvar variable will still be available, and will be its original type; $newvar is a completely new variable. 11/11/2018

36 Casting a Variable 1: <html> 2: <head>
3: <title> Casting a variable</title> 4: </head> 5: <body> 6: <?php 7: $undecided = 3.14; 8: $holder = ( double ) $undecided; 9: print gettype( $holder ) ; // double 10: print " -- $holder<br>"; // 3.14 11: $holder = ( string ) $undecided; 12: print gettype( $holder ); // string 13: print " -- $holder<br>"; // 3.14 11/11/2018

37 14: $holder = ( integer ) $undecided;
15: print gettype( $holder ); // integer 16: print " -- $holder<br>"; // 3 17: $holder = ( double ) $undecided; 18: print gettype( $holder ); // double 19: print " -- $holder<br>"; // 3.14 20: $holder = ( boolean ) $undecided; 21: print gettype( $holder ); // boolean 22: print " -- $holder<br>"; // 1 23: ?> 24: </body> 25: </html> We never actually change the type of $undecided, which remains a double throughout. Where we use the gettype() to determine the type of $undecided. 11/11/2018

38 Variable Variables A variable variable creates a new variable and assigns the current value of a variable as its name. Example: <?php $a = 'hello'; $$a = 'world'; echo "$a $hello"; echo $hello; ?> 11/11/2018

39 Comparisons of $x with PHP functions
Expression gettype() empty() is_null() isset() boolean : if($x) $x = ""; string TRUE FALSE $x = null; NULL var $x; $x is undefined $x = array(); array $x = false; boolean $x = true; $x = 1; integer $x = 42; $x = 0; $x = -1; $x = "1"; $x = "0"; $x = "-1"; $x = "php"; $x = "true"; $x = "false"; 11/11/2018

40 Open Source Programming
Operators All the operators such as arithmetic, assignment, Comparison, and logical operators are similar to the operators in C and C++. In PHP the string concatenation operator is denoted by ‘.’ For e.g. $name = “My name is”.$myname; Open Source Programming 11/11/2018

41 The Ternary Operator it takes three operands - a condition, a result for true, and a result for false. Syntax (Condition)? True: False ; Example: <?php     $agestr = ($age < 16) ? 'child' : 'adult'; ?> 11/11/2018

42 Open Source Programming
Quotes (“ Vs. ‘) In a double-quoted string variable names are expanded to their values. In a single-quoted string, no variable expansion takes place. $name = "Phil"; $age = 23; echo '$name is $age'; $name = "Phil"; $age = 23; echo “$name is $age”; Output is $name is $age Output is Phil is 23 Open Source Programming 11/11/2018

43 Open Source Programming
Operators (cont) Comparison Operator Logical Operator And Or ! Xor && ( high precedence) || ( high precedence) == != < > <= >= === (identical) 11/11/2018 Open Source Programming

44 Open Source Programming
Comment Line in PHP Single Line Comment - Single line comment in PHP is identified with //. <?Php // my first prg ?> Multi Lines Comment - Multi lines comment in PHP is identified by /* … */ <?Php /* line1 line2 line 3 */ ?> Open Source Programming 11/11/2018

45 Open Source Programming
Output in PHP 1. Echo & Print() is the common method in outputting data. Since it is a language construct, echo doesn’t require parenthesis like print(). 2. Output Text Usage: <?php echo “Hello World”; print(“Hello World”); // prints out Hello World ?> Open Source Programming 11/11/2018

46 Open Source Programming
Output in PHP 3. Output the value of a PHP variable: <?php echo $hits; // prints out the number of hits print ($hits); // returns a value if print process success. ?> 4. Can use “<br>”, to print in next line: <?php echo $a, “<br>”,$b ; //prints a & b in separate lines ?> Outputs Open Source Programming 11/11/2018

47 Open Source Programming
Conditional Statements (Branching) 1. If…else Statement – single decision stmt Syntax E.g. if (<condition>) { //True part Php code } else //False part php code if ($num1 > $num2) { $max = $num1; } else $max = $num2; Open Source Programming 11/11/2018

48 Conditional Statements (Branching)
2. If…else if Statement – multiple decision stmt Syntax if (<condition1>) { //True part Php code } else if (<condition2>) //1st False 2nd true part php code else // false part PhP code E.g. if ($num1 > $num2) { $max = $num1; } else if ($num2 > $num3) $max = $num3; else $max = $num2; Open Source Programming 11/11/2018

49 Conditional Statements (Branching)
3. Switch Statement – replacement of “if …… else if stmt”. E.g. Syntax switch ($day) { case 1: {echo “its Sunday”; break;} case 2: {echo “its Monday”; break;} ……… case 7: {echo “its Saturday”; break;} default: {echo “not specified value”;} } switch (expression) { case value1: {stmts1; break;} case value2: {stmts2; break;} ………… [default: stmts;] } Statements Open Source Programming 11/11/2018

50 Conditional Statements (Looping)
4. For Statement – replacement of “if …… else if stmt”. Syntax E.g. for( initial_expression; termination_check; index_updation) { statement (S); } for($i=1; $i < 10; $i++) echo $i; (or) $i=1; for(;$i<10;) { $i=$i+1; } 11/11/2018 Open Source Programming

51 Conditional Statements (Looping)
5. Do … While Statement Syntax E.g. do { Statement (S); } while (<condition>); do { $i=$i+1; echo $i; } while ($i < 10); Open Source Programming 11/11/2018

52 Conditional Statements (Looping)
5. While Statement Syntax E.g. while(<condition>) { Statement (S); } while ($i < 10) { $i=$i+1; echo $i; } Open Source Programming 11/11/2018

53 Open Source Programming
Arrays Generally, array is a collection of homogeneous elements. In Php, arrays are lists of bits of information mapped with keys and stored under one variable name. For example, you can store a person’s name and address or a list of states in one variable. Let’s store a person’s name and age under one variable name : $name = array(‘firstname’=>’Albert’,‘lastname’=>’Einstein’,‘age’=>124); Open Source Programming 11/11/2018

54 Open Source Programming
Arrays Array with Implicit key <?php $name[’firstname’] = “Albert”; $name[’lastname’] = “Einstein”; $name[’age’] = 124; ?> <?php $flavor[] = ‘blue rasberry’; $flavor[] = ‘root beer’; $flavor[] = ‘pineapple’; ?> Array with Explicit key Open Source Programming 11/11/2018

55 Multidimensional Arrays
Array of arrays is called as multidimensional arrays. $Student = array ( "0"=> array ("name"=>"James", "sex"=>"Male", "age"=>"28"), "1"=> array ("name"=>"John", "sex"=>"Male", "age"=>"25"), "2"=> array ("name"=>"Susan", "sex"=>"Female", "age"=>"24")); $student[“1"][“name"] – returns John Open Source Programming 11/11/2018

56 Open Source Programming
Array Functions Array(key=>value) – Creates an array with keys and values E.g.: <?php $a=array("a"=>"Dog","b"=>"Cat","c"=>"Horse"); print_r($a); ?> Output: Array ( [a] => Dog [b] => Cat [c] => Horse ) Open Source Programming 11/11/2018

57 Open Source Programming
Array Functions array_chunk(array,size,preserve_key ) - splits an array into chunks of new arrays Open Source Programming 11/11/2018

58 Open Source Programming
Array Functions E.g.: 1 <?php $a=array("a"=>"Cat","b"=>"Dog","c"=>"Horse","d"=>"Cow"); print_r(array_chunk($a,2)); ?> Output: Array ( [0] => Array ( [0] => Cat [1] => Dog ) [1] => Array ( [0] => Horse [1] => Cow ) ) Open Source Programming 11/11/2018

59 Open Source Programming
Array Functions E.g.: 2 <?php $a=array("a"=>"Cat","b"=>"Dog","c"=>"Horse","d"=>"Cow"); print_r(array_chunk($a,2,true)); ?> Output: Array ( [0] => Array ( [a] => Cat [b] => Dog ) [1] => Array ( [c] => Horse [d] => Cow ) ) Open Source Programming 11/11/2018

60 Open Source Programming
Array Functions array_combine(array1,array2) creates an array by combining two other arrays, where the first array is the keys, and the other array is the values. <?php $a1=array("a","b","c","d"); $a2=array("Cat","Dog","Horse","Cow"); print_r(array_combine($a1,$a2)); ?> E.g.: Array ( [a] => Cat [b] => Dog [c] => Horse [d] => Cow ) Output: Open Source Programming 11/11/2018

61 Open Source Programming
Array Functions array_count_values(array) returns an array, where the keys are the original array's values, and the values is the number of occurrences. <?php $a=array("Cat","Dog","Horse","Dog"); print_r(array_count_values($a)); ?> E.g: Array ( [Cat] => 1 [Dog] => 2 [Horse] => 1 ) Output: Open Source Programming 11/11/2018

62 Open Source Programming
Array Functions array_diff(arr1,arr2,…) function compares two or more arrays, and returns an array with the keys and values from the first array, only if the value is not present in any of the other arrays. <?php $a1=array(0=>"Cat",1=>"Dog",2=>"Horse"); $a2=array(3=>"Horse",4=>"Dog",5=>"Fish"); print_r(array_diff($a1,$a2)); ?> E.g: Array ( [0] => Cat ) Output: Open Source Programming 11/11/2018

63 Open Source Programming
Array Functions The array_diff_assoc(arr1, arr2,…) function compares two or more arrays, and returns an array with the keys and values from the first array, only if they are not present in any of the other arrays. <?php $a1=array(0=>"Cat",1=>"Dog";,2=>"Horse"); $a2=array(0=>"Rat",1=>"Horse";,2=>"Dog"); $a3=array(0=>"Horse",1=>"Dog",2=>"Cat"); print_r(array_diff_assoc($a1,$a2,$a3)); ?> E.g: Array ( [0] => Cat [2] => Horse ) Output: Open Source Programming 11/11/2018

64 Open Source Programming
Array Functions array_fill(start,number,value ) function returns an array filled with the values you describe <?php $a=array_fill(2,3,"Dog"); print_r($a); ?> E.g: Array ( [2] => Dog [3] => Dog [4] => Dog ) Output: Open Source Programming 11/11/2018

65 Open Source Programming
Array Functions The array_flip(array ) function returns an array with all the original keys as values, and all original values as keys. <?php $a=array(0=>"Dog",1=>"Cat",2=>"Horse"); print_r(array_flip($a)); ?> E.g: Array ( [Dog] => 0 [Cat] => 1 [Horse] => 2 ) Output: Open Source Programming 11/11/2018

66 Open Source Programming
Array Functions The array_key_exists(key,arr ) function checks an array for a specified key, and returns true if the key exists and false is the key does not exist. <?php $a=array("a"=>"Dog","b"=>"Cat"); if (array_key_exists("a",$a))     echo "Key exists!";   else     echo "Key does not exist!";   ?> E.g: Key exists! Output: Open Source Programming 11/11/2018

67 Open Source Programming
Array Functions The array_merge(array1,array2,array3...) function merges one ore more arrays into one array. <?php $a1=array("a"=>"Horse","b"=>"Dog"); $a2=array("c"=>"Cow","b"=>"Cat"); print_r(array_merge($a1,$a2)); ?> E.g: Array ( [a] => Horse [b] => Cat [c] => Cow ) Output: Up to D batch Open Source Programming 11/11/2018

68 Open Source Programming
Array Functions <?php $a=array(3=>"Horse",4=>"Dog"); print_r(array_merge($a)); ?> E.g: Array ( [0] => Horse [1] => Dog ) Output: Open Source Programming 11/11/2018

69 Open Source Programming
Array Functions array_multisort(array1, sortingorder, sorting type, array2, array3 ) returns a sorted array. You can assign one or more arrays. <?php $a1=array(“Dog","Cat"); $a2=array("Fido","Missy"); array_multisort($a1,$a2); print_r($a1); print_r($a2); ?> E.g: Array ( [0] => Cat [1] => Dog ) Array ( [0] => Missy [1] => Fido ) Output: Open Source Programming 11/11/2018

70 Open Source Programming
Array Functions <?php $a1=array("Dog","Dog","Cat"); $a2=array("Pluto","Fido","Missy"); array_multisort($a1,SORT_ASC,$a2,SORT_DESC); print_r($a1); print_r($a2); ?> E.g: Array ( [0] => Cat [1] => Dog [2] => Dog ) Array ( [0] => Missy [1] => Pluto [2] => Fido ) Output: Open Source Programming 11/11/2018

71 Open Source Programming
Array Functions The array_pop(array) function deletes the last element of an array. Array_shift(array) – removes an element at the beginning of the array <?php $a=array("Dog","Cat","Horse"); array_pop($a); print_r($a); array_shift($a); print_r($a); ?> E.g: Array ( [0] => Dog [1] => Cat ) Array ( [0] => Cat ) Output: Open Source Programming 11/11/2018

72 Open Source Programming
Array Functions The array_push(array,value1,value2...) function inserts one or more elements to the end of an array. Array_unshift(array) – inserts an element at the beginning of the array <?php $a=array("Dog","Cat"); array_push($a,"Horse","Bird"); Print_r($a); array_unshift($a, “fish”); print_r($a); ?> E.g: Array ( [0] => Dog [1] => Cat [2] => Horse [3] => Bird ) Array ( [0] => fish [1]=>Dog [2] => Cat [3] => Horse [4] => Bird ) Output: Open Source Programming 11/11/2018

73 Open Source Programming
Array Functions Output ???????? <?php $a=array("a"=>"Dog","b"=>"Cat"); array_push($a,"Horse","Bird"); print_r($a); ?> E.g: Array ( [a] => Dog [b] => Cat [0] => Horse [1] => Bird ) Output: Open Source Programming 11/11/2018

74 Open Source Programming
Array Functions array_rand(array,num) function returns a random key from an array, or it returns an array of random keys if you specify that the function should return more than one key. <?php $a=array("a"=>"Dog","b"=>"Cat","c"=>"Horse"); print_r(array_rand($a,1)); ?> E.g: b Output: Open Source Programming 11/11/2018

75 Open Source Programming
Array Functions The array_reverse(array,preserve) function returns an array in the reverse order. <?php $a=array("a"=>"Dog","b"=>"Cat","c"=>"Horse"); print_r(array_reverse($a)); ?> E.g: Array ( [c] => Horse [b] => Cat [a] => Dog ) Output: Open Source Programming 11/11/2018

76 Open Source Programming
Array Functions The array_search(value,array,strict ) function search an array for a value and returns the key. <?php $a=array("a"=>"Dog","b"=>"Cat","c"=>"Horse"); echo array_search("Dog",$a); ?> E.g: a Output: Open Source Programming 11/11/2018

77 Open Source Programming
Array Functions The array_slice(array, start, length, preserve) function returns selected parts of an array. <?php $a=array(0=>"Dog",1=>"Cat",2=>"Horse",3=>"Bird"); print_r(array_slice($a,1,2)); ?> E.g: Array ( [0] => Cat [1] => Horse ) Output: Open Source Programming 11/11/2018

78 Open Source Programming
Array Functions The array_splice(array,start,length,array) function removes selected elements from an array and replaces it with new elements. The function also returns an array with the removed elements. <?php $a1=array(0=>"Dog",1=>"Cat",2=>"Horse",3=>"Bird"); $a2=array(0=>"Tiger",1=>"Lion"); array_splice($a1,0,2,$a2); print_r($a1); ?> E.g: Array ( [0] => Tiger [1] => Lion [2] => Horse [3] => Bird ) Output: Open Source Programming 11/11/2018

79 Open Source Programming
Array Functions The array_sum(array) function returns the sum of all the values in the array. <?php $a=array(0=>"5",1=>"15",2=>"25"); echo array_sum($a); ?> E.g: 45 Output: Open Source Programming 11/11/2018

80 Open Source Programming
Array Functions The arsort(array,sorttype) function sorts an array by the values in reverse order. The values keep their original keys. <?php $my_array = array("a" => "Dog", "b" => "Cat", "c" => "Horse"); arsort($my_array); print_r($my_array); ?> E.g: Array ( [c] => Horse [a] => Dog [b] => Cat ) Output: Open Source Programming 11/11/2018

81 Open Source Programming
Array Functions The asort(array,sorttype) function sorts an array by the values. The values keep their original keys <?php $my_array = array("a" => "Dog", "b" => "Cat", "c" => "Horse"); asort($my_array); print_r($my_array); ?> E.g: Array ( [b] => Cat [a] => Dog [c] => Horse ) Output: Open Source Programming 11/11/2018

82 Open Source Programming
Array Functions The krsort(array,sorttype) function sorts an array by the keys in reverse order. The values keep their original keys. <?php $my_array = array("a" => "Dog", "b" => "Cat", "c" => "Horse"); krsort($my_array); print_r($my_array); ?> E.g: Array ( [c] => Horse [b] => Cat [a] => Dog ) Output: Open Source Programming 11/11/2018

83 Open Source Programming
Array Functions The ksort(array,sorttype) function sorts an array by the keys. The values keep their original keys. <?php $my_array = array("a" => "Dog", "b" => "Cat", "c" => "Horse"); ksort($my_array); print_r($my_array); ?> E.g: Array ( [a] => Dog [b] => Cat [c] => Horse ) Output: Open Source Programming 11/11/2018

84 Open Source Programming
Array Functions The rsort(array,sorttype) function sorts an array by the values in reverse order. This function assigns new keys for the elements in the array. Existing keys will be removed. This function returns TRUE on success, or FALSE on failure. <?php $my_array = array("a" => "Dog", "b" => "Cat", "c" => "Horse"); rsort($my_array); print_r($my_array); ?> E.g: Array ( [0] => Horse [1] => Dog [2] => Cat ) Output: Open Source Programming 11/11/2018

85 Open Source Programming
Array Functions The sort(array,sorttype) function sorts an array by the values. This function assigns new keys for the elements in the array. Existing keys will be removed. This function returns TRUE on success, or FALSE on failure <?php $my_array = array("a" => "Dog", "b" => "Cat", "c" => "Horse"); sort($my_array); print_r($my_array); ?> E.g: Array ( [0] => Cat [1] => Dog [2] => Horse ) Output: Open Source Programming 11/11/2018

86 Open Source Programming
Array Functions Other Array Functions: Array array range(low,high,step) – Populates the array from low value to high value with the interval of step. boolean is_array(variable name) – Used to check for an array Array Array_keys(arrayname) – retrieves keys from the array. Array array_values(array) – retrieves values Int count(arrayname[,mode]) – counts values in an array. Mode – 1 counts recursively (ie for 2dim array) Sizeof – alias of count. Open Source Programming 11/11/2018

87 Open Source Programming
Array Constants CASE_LOWER CASE_UPPER SORT_ASC SORT_DESC SORT_REGULAR SORT_NUMERIC SORT_STRING SORT_LOCALE_STRING COUNT_NORMAL COUNT_RECURSIVE EXTR_OVERWRITE EXTR_SKIP EXTR_PREFIX_SAME EXTR_PREFIX_ALL EXTR_PREFIX_INVALID EXTR_PREFIX_IF_EXISTS EXTR_IF_EXISTS EXTR_REFS Open Source Programming 11/11/2018

88 Open Source Programming
String Functions The count_chars(string,mode ) function returns how many times an ASCII character occurs within a string and returns the information. Array ( [32] => 1 [33] => 1 [72] => 1 [87] => 1 [100] => 1 [101] => 1 [108] => 3 [111] => 2 [114] => 1 ) Output: <?php $str = "Hello World!"; print_r(count_chars($str,1)); ?> E.g: Open Source Programming 11/11/2018

89 Open Source Programming
String Functions The different return modes are: 0 - an array with the ASCII value as key and number of occurrences as value 1 - an array with the ASCII value as key and number of occurrences as value, only lists occurrences greater than zero 2 - an array with the ASCII value as key and number of occurrences as value, only lists occurrences equal to zero are listed 3 - a string with all the different characters used 4 - a string with all the unused characters Open Source Programming 11/11/2018

90 Open Source Programming
String Functions The explode(separator, string, limit) function breaks a string into an array. Output: Array ( [0] => Hello [1] => world. [2] => It's [3] => a [4] => beautiful [5] => day. ) <?php $str = "Hello world. It's a beautiful day."; print_r (explode(" ",$str)); ?> E.g: Open Source Programming 11/11/2018

91 Open Source Programming
String Functions The implode(separator,array ) & join(separator,array ) function returns a string from the elements of an array. <?php $arr = array('Hello','World!','Beautiful','Day!'); echo implode(" ",$arr); ?> E.g: Output: Hello World! Beautiful Day! Open Source Programming 11/11/2018

92 Open Source Programming
String Functions The ltrim(string,charlist) & rtrim(string,charlist) function will remove whitespaces or other predefined character from the left and right side of a string respectively. The soundex(string) function calculates the soundex key of a string. The str_shuffle(string) function randomly shuffles all the characters of a string. DBatch stop Open Source Programming 11/11/2018

93 Open Source Programming
String Functions The strlen(string) function returns the length of a string. <?php $a= “hello World!”; echo “Length = “, strlen($a); ?> E.g: Output: Length = 12 Open Source Programming 11/11/2018

94 Open Source Programming
String Functions The strrev(string) reverses the given string. <?php $a= “hello World!”; echo “Reverse of \”$a\” is “, strrev($a); ?> E.g: Output: Reverse of “hello World!” is !dlroW olleh Open Source Programming 11/11/2018

95 Open Source Programming
String Functions The strtoupper(string) converts to upper case character The strtolower(string) converts to lower case character <?php $a= “hello World!”; echo “Upper of \”$a\” is “, strtoupper($a); echo “Lower of \”$a\” is “, strtolower($a); ?> E.g: Output: Upper of “hello World!” is HELLO WORLD! Lower of “hello World!” is hello world Open Source Programming 11/11/2018

96 Open Source Programming
String Functions The strpos(string,exp) returns the numerical position of first appearance of exp. The strrpos(string,exp) returns the numerical position of last appearance of exp. <?php $a= “hello World!”; echo strpos($a,”l”),”<br>”; echo strrpos($a,”l”); ?> E.g: Output: 2 10 Open Source Programming 11/11/2018

97 Open Source Programming
String Functions The substr(string,start,length) function returns a sub string of the size “length” from the position of “start”. <?php $a= “hello World!”; echo substr($a,3,2); ?> E.g: Output: lo Open Source Programming 11/11/2018

98 Open Source Programming
String Functions The substr_count(string,substr) counts number of times a sub string occurred in given string. <?php $a= “hello Worlod!”; echo substr_count($a,”lo”); ?> E.g: Output: 2 Open Source Programming 11/11/2018

99 Open Source Programming
String Functions The ucfirst(string) converts the first character to upper case. The ucwords(string) converts the first character of each word to upper case. <?php $a= “hello world!”; echo ucfirst($a),”<br>”; echo ucwords($a); ?> E.g: Output: Hello world! Hello World! Open Source Programming 11/11/2018

100 Open Source Programming
String Functions The parse_str(string,arr) function parses a query string into variables. <?php parse_str("id=23&name=Kai%20Jim"); echo $id."<br />"; echo $name; ?> E.g: Output: 23 Kai Jim Open Source Programming 11/11/2018

101 Open Source Programming
String Functions The str_replace(find,replace,string,count ) function replaces some characters with some other characters in a string. Note: str_ireplace() – for case sensitive Output: <?php $arr = array("blue","red","green","yellow"); print_r(str_ireplace("RED","pink",$arr,$i)); echo "Replacements: $i"; ?> E.g: Array ( [0] => blue [1] => pink [2] => green [3] => yellow ) Replacements: 1 Open Source Programming 11/11/2018

102 Open Source Programming
String Functions The str_pad(string,length,padchar,padtype) function pads a string to a new length. <?php $str = "Hello World"; echo str_pad($str,20,".",STR_PAD_LEFT); ?> E.g: Output: Hello World Open Source Programming 11/11/2018

103 Open Source Programming
String Functions The str_split(string,length ) function splits a string into an array. Default length is 1. <?php print_r(str_split("Hello",3)); ?> E.g: Output: Array ( [0] => Hel [1] => lo ) Open Source Programming 11/11/2018

104 Open Source Programming
String Functions The str_word_count(string) function counts the number of words in a string. <?php echo str_word_count("Hello world!"); ?> E.g: Output: 2 Open Source Programming 11/11/2018

105 Open Source Programming
String Functions The strcasecmp(string1,string2) function compares two strings as case insensitive. Strcmp(string1,string2) compares as case sensitive. This function returns: 0 - if the two strings are equal < 0 - if string1 is less than string2 > 0 - if string1 is greater than string2 <?php echo strcasecmp("Hello world!","HELLO WORLD!"); echo “<br>”; echo strcmp("Hello world!","HELLO WORLD!"); ?> E.g: Output: 1 Open Source Programming 11/11/2018

106 Open Source Programming
String Functions The stripos(string,find,start) function returns the position of the first occurrence of a string inside another string. Strpos(string,find,start) – case sensitive. If the string is not found, this function returns FALSE. <?php echo stripos("Hello world!","WO"); ?> E.g: Output: 6 Open Source Programming 11/11/2018

107 Open Source Programming
String Functions The stristr(string,exp) function searches for the first occurrence of a string inside another string. This function returns the rest of the string (from the matching point), or FALSE, if the string to search for is not found <?php echo stristr("Hello world! Have a nice day","WORLD"); ?> E.g: Output: World! Have a nice day Open Source Programming 11/11/2018

108 Open Source Programming
Date Functions Boolean Checkdate(day,month,year) – used to check the given parameters are a valid date. Date(formatstring) - The date() function returns a string representation of the current date and/or time formatted according to the instructions specified by a predefined format. Array Getdate(int timestamp) – returns array of datetime components Time() – returns time stamp Mktime(int h,int min, int sec, int day, int mnth, int yr) – create a date and time Open Source Programming 11/11/2018

109 Open Source Programming
Math Functions Some mathematical functions are listed: sin(X) , cos(x), tan(x), asin(x), acos(x), atan(x), exp(x), log(x) – are trigonometric functions returns the respected values. Ceil(x), floor(x) – used to round the numbers. Abs(x) – returns absolute value for the given number. Fmod(x,y) – returns the reminder of the division x /y. Min(x,y) & Max(x,y) – returns the min and max values respectively. Bindec(x), binoct(x),binhex(x) – converts the given binary value into decimal, octal and hexadecimal. decbin(x), decoct(x), dechex(x) – converts the given decimal value into binary, octal and hexadecimal. Base_convert(val,bastype, convtype) – converts the given value of basetype has to be converted to the convtype. Open Source Programming 11/11/2018

110 Open Source Programming
Super Globals PHP offers a number of useful predefined variables that are accessible from anywhere within the executing script and provide you with a substantial amount of environment-specific information. You can sift through these variables to retrieve details about the current user session, the user’s operating environment, the local operating environment, and more. They are: $_SERVER $_GET $_POST $_COOKIE $_ENV $_SESSION $_FILES Open Source Programming 11/11/2018

111 Open Source Programming
Super Globals $_SERVER: The $_SERVER super global contains information created by the Web server and offers a bevy of information regarding the server and client configuration and the current request environment. $_GET & $_POST: The $_GET and $_POST super globals are used to retrieve information from forms, like user input. $_COOKIE: The $_COOKIE super global stores information passed into the script through HTTP cookies Open Source Programming 11/11/2018

112 Open Source Programming
Super Globals $_ENV: The $_ENV super global offers information regarding the PHP parser’s underlying server environment. $_SESSION: The $_SESSION super global contains information regarding all session variables $_FILES: The $_FILES super global contains information regarding data uploaded to the server via the POST method. This super global is a tad different from the others. Open Source Programming 11/11/2018

113 Open Source Programming
Functions Functions: A function is a block of code that is not immediately executed but can be called by scripts whenever needs. Functions can be built-in or user-defined. They can require information to be passed to them and usually return a value. Open Source Programming 11/11/2018

114 User Defined Functions
Creating Function: Function names follow the same rules as other labels in PHP. A valid function name starts with a letter or underscore, followed by any number of letters, numbers, or underscores. A piece of information passed to a function is called an argument. Some functions require that more than one argument be passed to them. Arguments in these cases must be separated by commas: Open Source Programming 11/11/2018

115 User Defined Functions
Function E.g. <?php function generateFooter() { echo "Copyright 2007 W. Jason Gilmore"; } // Once defined, call the function likes so: generateFooter(); // function calling ?> Output: Copyright 2007 W. Jason Gilmore Open Source Programming 11/11/2018

116 User Defined Functions
Function Call: A function call consists of the functionName(parameters) followed by parentheses. A function can return a value using the return statement in conjunction with a value or object. The function can be called as pass-by-value and pass-by-reference. By default, parameters are passed to functions by value. Open Source Programming 11/11/2018

117 User Defined Functions
Function with argument: <?php function writeName($fname) { echo $fname . " Refsnes.<br />"; } echo "My name is "; writeName("Kai Jim"); echo "My sister's name is "; writeName("Hege"); echo "My brother's name is "; writeName("Stale"); ?> Formal Argument Fn. Call with Actual Argument Output: My name is Kai Jim Refsnes. My sister's name is Hege Refsnes. My brother's name is Stale Refsnes. Open Source Programming 11/11/2018

118 User Defined Functions
Function with arguments & return value: <?php function calculateAmt($cost, $num) { return ($cost * $num); } $price=10; $tot=5; Echo “ Total Amount “, calculateAmt($price, $tot); ?> Output: Total Amount 50 Open Source Programming 11/11/2018

119 User Defined Functions
Fn. Call by Ref.: <?php $cost = 20.99; $tax = ; function calculateCost(&$cost, $tax) { // Modify the $cost variable $cost = $cost + ($cost * $tax); // Perform some random change to the $tax variable. $tax += 4; } Echo “(bfr fn call) Cost is $cost <br>”; calculateCost($cost, $tax); Echo "Tax is $tax*100 <br>"; Echo “(aft fn call) Cost is: $cost”; ?> Output: (bfr fn call) Cost is 20.99 Tax is 5.75 (aft fn call) Cost is: 22.20 Open Source Programming 11/11/2018

120 User Defined Functions
Variable Scope: Variables used inside a function are different from those used outside a function. The variables used inside the function are limited to the scope of the function. The global statement declares a variable within a function as being the same as the variable that is used outside of the function. Open Source Programming 11/11/2018

121 User Defined Functions
Fn. With global variable: <?php function doublevalue( ) { global $temp; $temp = $temp * 2; } $temp = 5; doublevalue( ); echo “Temp is: $temp"; ?> Output: Temp is: 10 Open Source Programming 11/11/2018

122 Open Source Programming
PHP Form Handling <form method = POST action = form.php> Name: <input type =text name = fname> <br> Age: <input type = text name = age> <br> <input type = submit value = submit> </form> HTML Code (Form.html) <?php $a = $_POST['fname']; $b = $_POST['age']; echo "Welcome Mr./Ms. $a. You are $b years old "; ?> PHP Code (form.php) Open Source Programming 11/11/2018

123 Open Source Programming
PHP Form Handling HTML Browser Result Open Source Programming 11/11/2018

124 PHP $_GET Function The built-in $_GET function is used to collect values in a form with method="get". Information sent from a form with the GET method is visible to everyone. (It will be displayed in the browser's address bar) and has limits on the amount of information to send (max. 100 characters). 11/11/2018

125 PHP $_POST Function The built-in $_POST function is used to collect values in a form with method="post". Information sent from a form with the POST method is invisible to others POST Method has no limits on the amount of information to send. 11/11/2018

126 The PHP $_REQUEST Function
The PHP built-in $_REQUEST function contains the contents of both $_GET, $_POST. The $_REQUEST function can be used to collect form data sent with both the GET and POST methods. 11/11/2018

127 Forms with HTML The most important thing to notice when dealing with HTML forms and PHP is that any form element in an HTML page will automatically be available to your PHP scripts. 11/11/2018

128 Exception Handling PHP
1. The application attempts something. 2. If the attempt fails, the exception-handling feature throws an exception. 3. The assigned handler catches the exception and performs any necessary tasks. 4.The exception-handling feature cleans up any resources consumed during the attempt. In PHP, Exception handling can be done by try …throw… catch. Open Source Programming Open Source Programming 11/11/2018

129 Exception Handling PHP
Exception handling syntax: Try { statement block; if goes wrong throw new exception(error message) } catch (exception $E) echo $E.getMessage(); } Open Source Programming Open Source Programming 11/11/2018

130 Exception Handling in PHP
$a=10; $b=0; try { if ($b == 0) throw new exception("Divide by zero error"); $c = $a/$b; echo " $a"," / ","$b = ", $a/$b; } catch(Exception $e) { echo $e->getMessage(); } ?> Output: Divide by zero error Open Source Programming 11/11/2018

131 Object Oriented PHP - Class
Basic class definitions begin with the keyword class, followed by a class name, followed by a pair of curly braces which enclose the definitions of the properties and methods belonging to the class. The class name can be any valid label which is a not a PHP reserved word. A valid class name starts with a letter or underscore, followed by any number of letters, numbers, or underscores. A class may contain its own constants, variables (called "properties"), and functions (called "methods"). $this is a variable that indicates the current object. For instance, $this->a gets the data from the $a variable in the object. Open Source Programming 11/11/2018

132 Object Oriented PHP - Object
E.g.: <?php class SimpleClass {     // property declaration     public $var = ‘Hello';     // method declaration     public function displayVar()  {         echo $this->var;     } $obj1 = new SimpleClass(); $Obj1->displayVar(); } ?> To create an instance of a class, the new keyword must be used. Now any abc object that is created contains a property called $var with the value of “Hello”. This property can be accessed and even be changed with the help of objects. In this, the -> operator is used to access the properties or methods of the object. Open Source Programming 11/11/2018

133 Open Source Programming
Inheritance A class can inherit the methods and properties of another class by using the keyword extends in the class declaration. It is not possible to extend multiple classes; a class can only inherit from one base class. The inherited methods and properties can be overridden by redeclaring them with the same name defined in the parent class. However, if the parent class has defined a method as final, that method may not be overridden. It is possible to access the overridden methods or static properties by referencing them with parent. Abstract methods are special in that they are declared only within a parent class but are implemented in child classes. Only classes declared as abstract can contain abstract methods. Open Source Programming 11/11/2018

134 Open Source Programming
Inheritance E.G. <?php class ExtendClass extends SimpleClass {     // Redefine the parent method     function displayVar()     {         echo "Extending class\n";         parent::displayVar();     } } $extended = new ExtendClass(); $extended->displayVar(); ?> Output: Extending class Hello Open Source Programming 11/11/2018

135 Constructors & Destructors
A constructor is defined as a block of code that automatically executes at the time of object instantiation. PHP recognizes constructors by the name __construct(). PHP does not automatically call the parent constructor; you must call it explicitly using the parent keyword. Destructors are created like any other method but must be titled __destruct(). Open Source Programming 11/11/2018

136 Constructors & Destructors
E.g. <?php class BaseClass {    function __construct() {        print "In BaseClass constructor\n";    } } class SubClass extends BaseClass {    function __construct() {        parent::__construct();        print "In SubClass constructor\n";    } } $obj = new BaseClass(); $obj = new SubClass(); ?> Output: In BaseClass constructor In BaseClass constructor In SubClass constructor Open Source Programming 11/11/2018

137 Open Source Programming
Files Organizing related data into entities commonly referred to as files. To create a file we use fopen Function. The fopen function needs two important pieces of information to operate correctly. First parameter requires file name to open. Second parameter indicates the mode in which the file has to be opened. E.g. <?php $ourFileName = "testFile.txt"; $ourFileHandle = fopen($ourFileName, ‘w') or die("can't open file"); ?> Open Source Programming 11/11/2018

138 Open Source Programming
Files Some modes are Open Source Programming 11/11/2018

139 Files File closing can be done by fclose(fp); E.g.
<?php $ourFileName = "testFile.txt"; $ourFileHandle = fopen($ourFileName, ‘w') or die("can't open file"); fclose($ourFileHandle); ?> 11/11/2018

140 Open Source Programming
Some File Functions 1) fopen(filename,mode) - used for opening a file with specific mode. 2) fclose(fp) - used to close the file. (fp -> filepointer) 3) feof(fp) - used to find the End of File 4) fgetc(fp) - Gets character from file pointer 5) fgets(fp) - Gets a line from file pointer 6) fread(fp,size) - Binary-safe file read 7) fscanf(fp,format) - Parses input from a file according to a format 8) fwrite(fp,string) - Binary-safe file write 9) file_put_contents(fp,string) - Write a string to a file 10) file_get_contents(fp) - Reads entire file into a string 11) file(fp) - Reads entire file into an array 12) file_exists(fp) - Checks whether a file or directory exists Open Source Programming 11/11/2018

141 Open Source Programming
Some File Functions 13) is_readable(fp) - Tells whether the filename is readable 14) is_writable(fp) - Tells whether the filename is writable 15) is_file(path) - Tells whether the filename is a regular file 16) is_dir(path) - Tells whether the filename is a directory 17) is_link(path) - Tells whether the filename is a symbolic link 18) readlink(path) - Returns the target of a symbolic link 19) readdir - Read entry from directory handle 20) glob - Find pathnames matching a pattern 21) filesize(fp) - Gets file size 22) filetype(fp) - Gets file type 23) fprintf(fp,format) - Write a formatted string to a stream 24) fstat(fp) - Gets information about a file using an open file pointer Open Source Programming 11/11/2018

142 Open Source Programming
File Write <?php $myFile = "testFile.txt"; $fh = fopen($myFile, 'w') or die("can't open file"); $stringData = "Bobby Bopper\n"; fwrite($fh, $stringData); $stringData = "Tracy Tanner\n"; fwrite($fh,$stringData); fclose($fh); ?> Open Source Programming 11/11/2018

143 Open Source Programming
File Read E.g. <?php // get contents of a file into a string $filename = "testfile.txt"; $handle = fopen($filename, "r"); //$contents = fread($handle, filesize($filename)); while (!feof($handle)) echo fgetc($handle),"<br>"; //print_r("$contents"); fclose($handle); ?> Output: Bobby Bopper Tracy Tanner Open Source Programming 11/11/2018

144 Open Source Programming
File Append E.g. <?php $myFile = "testFile.txt"; $fh = fopen($myFile, 'a+') or die("can't open file"); $stringData = "new1"; fwrite($fh, $stringData); $stringData = "new2\n"; fclose($fh); ?> Output: Bobby Bopper Tracy Tannernew1new2 Open Source Programming 11/11/2018

145 Open Source Programming
Include & Require Can insert the content of one PHP file into another PHP file before the server executes it, with the include() or require() function. The two functions are identical in every way, except how they handle errors: 1. include() generates a warning, but the script will continue execution 2. require() generates a fatal error, and the script will stop E.g. <?php include("wrongFile.php"); echo "Hello World!"; ?> Output: Error Message Hello World Open Source Programming 11/11/2018

146 Open Source Programming
Include & Require E.g. <?php require("wrongFile.php"); echo "Hello World!"; ?> Output: Error Message Open Source Programming 11/11/2018

147 Open Source Programming
File Upload With PHP, it is possible to upload files to the server. HTML SCRIPT to allow users to upload files from a form. By using the global PHP $_FILES array you can upload files from a client computer to the remote server. The first parameter is the form's input name and the second index can be either "name", "type", "size", "tmp_name" or "error". Like this: $_FILES["file"]["name"] - the name of the uploaded file $_FILES["file"]["type"] - the type of the uploaded file $_FILES["file"]["size"] - the size in bytes of the uploaded file $_FILES["file"]["tmp_name"] - the name of the temporary copy of the file stored on the server $_FILES["file"]["error"] - the error code resulting from the file upload Open Source Programming 11/11/2018

148 Open Source Programming
File Upload E.g. <html> <body> <form action="upload_file.php" method="post" enctype="multipart/form-data"> <label for="file">Filename:</label> <input type="file" name="file" id="file" />  <br /> <input type="submit" name="submit" value="Submit" /> </form> </body> </html> The enctype attribute of the <form> tag specifies which content-type to use when submitting the form. "multipart/form-data" is used when a form requires binary data, like the contents of a file, to be uploaded. The type="file" attribute of the <input> tag specifies that the input should be processed as a file. Open Source Programming 11/11/2018

149 Open Source Programming
Adding Restrictions <?php //upload_file1.php if ((($_FILES["file"]["type"] == "image/gif") || ($_FILES["file"]["type"] == "image/jpeg") || ($_FILES["file"]["type"] == "image/pjpeg")) && ($_FILES["file"]["size"]/1024 < 20))   {   if ($_FILES["file"]["error"] > 0)     {     echo "Error: " . $_FILES["file"]["error"] . "<br />";     }   else     {     echo "Upload: " . $_FILES["file"]["name"] . "<br />";     echo "Type: " . $_FILES["file"]["type"] . "<br />";     echo "Size: " . ($_FILES["file"]["size"] / 1024) . " Kb<br />";     echo "Stored in: " . $_FILES["file"]["tmp_name"];     }   } else   {   echo "Invalid file";   } ?> Open Source Programming 11/11/2018

150 Open Source Programming
Unit-I Ends Open Source Programming 11/11/2018


Download ppt "Open Source Programming"

Similar presentations


Ads by Google