{"id":341,"date":"2018-07-27T10:36:09","date_gmt":"2018-07-27T10:36:09","guid":{"rendered":"http:\/\/csp12.epgpbooks.inflibnet.ac.in\/?post_type=chapter&#038;p=341"},"modified":"2018-07-27T10:36:10","modified_gmt":"2018-07-27T10:36:10","slug":"php-ii","status":"publish","type":"chapter","link":"https:\/\/ebooks.inflibnet.ac.in\/csp12\/chapter\/php-ii\/","title":{"rendered":"PHP \u2013 II"},"content":{"raw":"<div>\r\n\r\n<strong>\u00a0 Learning Objectives<\/strong>\r\n\r\n&nbsp;\r\n<p style=\"text-align: justify\">This module is intended to learn about the PHP Strings, usage of various PHP operators, different types of PHP functions and PHP Arrays for successful PHP scripts programming and deployment in Web server.<\/p>\r\n&nbsp;\r\n\r\n<strong>1.<\/strong>\u00a0\u00a0\u00a0 <strong>PHP String<\/strong>\r\n\r\n&nbsp;\r\n<p style=\"text-align: justify\">A string is series of characters, where a character is the same as a byte. This means that PHP only supports a 256-character set, and hence does not offer native Unicode support.<\/p>\r\n&nbsp;\r\n\r\n<strong>2.\u00a0\u00a0 PHP Operators<\/strong>\r\n\r\n&nbsp;\r\n\r\nPHP operator is a symbol that is used to perform operations on various operands. For example:\r\n<p style=\"text-align: justify\">$num=10+20;\/\/+ is the operator and 10, 20 are operands.In the above example, + is the binary operator, 10 and 20 are operands and $num is a variable.Operators are used to perform operations on variables and values.Operators in PHP are similar to those found in many modern C-like programming languages.PHP divides the available set of operators in the following groups:<\/p>\r\nArithmetic operators Assignment operators Comparison operators\r\n\r\nIncrement\/Decrement operators Logical operators\r\n\r\nString operators Array operators\r\n<p style=\"text-align: justify\">We can also categorize operators on behalf of operands. Using Operators, they can be categorized in 3 forms:<\/p>\r\n&nbsp;\r\n\r\n<strong>Unary Operators: <\/strong>works on single operands such as ++, -- etc.\r\n\r\n<strong style=\"text-align: initial;font-size: 1em\">Binary Operators: <\/strong><span style=\"text-align: initial;font-size: 1em\">works on two operands such as binary +, -, *, \/ etc.<\/span>\r\n\r\n<strong style=\"text-align: initial;font-size: 1em\">Ternary Operators: <\/strong><span style=\"text-align: initial;font-size: 1em\">works on three operands such as \"?:\".<\/span>\r\n\r\n&nbsp;\r\n\r\n<strong style=\"text-align: initial;font-size: 1em\">2.1 PHP Arithmetic Operators<\/strong>\r\n\r\n<\/div>\r\n<p style=\"text-align: justify\">\u00a0 The PHP arithmetic operators are used along with numerical values to perform common arithmetical operations, such as addition, subtraction, multiplication and divisionas shown in Table 1.<\/p>\r\n&nbsp;\r\n<p style=\"text-align: center\"><img class=\"size-full wp-image-342 aligncenter\" src=\"http:\/\/csp12.epgpbooks.inflibnet.ac.in\/wp-content\/uploads\/sites\/60\/2018\/07\/Untitled-212.png\" alt=\"\" width=\"626\" height=\"288\" \/><\/p>\r\n&nbsp;\r\n\r\n<strong>2.2 PHP Assignment Operators<\/strong>\r\n\r\n&nbsp;\r\n<p style=\"text-align: justify\">The PHP assignment operators are used along with numerical values to assign a value to a variable.The basic assignment operator in PHP is \"=\". Different Assignment operators available in PHP script is shown in Table 2.<\/p>\r\n&nbsp;\r\n<p style=\"text-align: center\"><img class=\"size-full wp-image-343 aligncenter\" src=\"http:\/\/csp12.epgpbooks.inflibnet.ac.in\/wp-content\/uploads\/sites\/60\/2018\/07\/Untitled-213.png\" alt=\"\" width=\"498\" height=\"272\" \/><\/p>\r\n<p style=\"text-align: center\"><img class=\"size-full wp-image-344 aligncenter\" src=\"http:\/\/csp12.epgpbooks.inflibnet.ac.in\/wp-content\/uploads\/sites\/60\/2018\/07\/Untitled-214.png\" alt=\"\" width=\"482\" height=\"169\" \/><\/p>\r\n&nbsp;\r\n\r\n<strong>2.3 PHP Comparison Operators<\/strong>\r\n\r\n&nbsp;\r\n<p style=\"text-align: justify\">The PHP comparison operators are used to compare two values (number or string) as shown in Table 3.<\/p>\r\n&nbsp;\r\n<p style=\"text-align: center\"><img class=\"size-full wp-image-345 aligncenter\" src=\"http:\/\/csp12.epgpbooks.inflibnet.ac.in\/wp-content\/uploads\/sites\/60\/2018\/07\/Untitled-215.png\" alt=\"\" width=\"560\" height=\"487\" \/><\/p>\r\n&nbsp;\r\n\r\n<strong>2.4 PHP Increment \/ Decrement Operators<\/strong>\r\n\r\n&nbsp;\r\n<p style=\"text-align: justify\">The PHP increment\/decrement operators are used to increment\/decrement the value of the variable as shown in Table 4.<\/p>\r\n&nbsp;\r\n<p style=\"text-align: center\"><img class=\"size-full wp-image-346 aligncenter\" src=\"http:\/\/csp12.epgpbooks.inflibnet.ac.in\/wp-content\/uploads\/sites\/60\/2018\/07\/Untitled-216.png\" alt=\"\" width=\"509\" height=\"204\" \/><\/p>\r\n&nbsp;\r\n\r\n<strong>2.5 PHP Logical Operators<\/strong>\r\n\r\n&nbsp;\r\n\r\nThe PHP logical operators are used to combine conditional statements as shown in Table 5.\r\n\r\n&nbsp;\r\n<p style=\"text-align: center\"><img class=\"size-full wp-image-347 aligncenter\" src=\"http:\/\/csp12.epgpbooks.inflibnet.ac.in\/wp-content\/uploads\/sites\/60\/2018\/07\/Untitled-217.png\" alt=\"\" width=\"572\" height=\"349\" \/><\/p>\r\n&nbsp;\r\n\r\n<strong>2.6 PHP String Operators<\/strong>\r\n\r\n&nbsp;\r\n<p style=\"text-align: justify\">PHP has two operators that are specially designed to perform operations on strings as shown in Table 6.<\/p>\r\n&nbsp;\r\n<p style=\"text-align: center\"><img class=\"size-full wp-image-348 aligncenter\" src=\"http:\/\/csp12.epgpbooks.inflibnet.ac.in\/wp-content\/uploads\/sites\/60\/2018\/07\/Untitled-218.png\" alt=\"\" width=\"526\" height=\"258\" \/><\/p>\r\n&nbsp;\r\n\r\n<strong>2.7 PHP Array Operators<\/strong>\r\n\r\n&nbsp;\r\n<p style=\"text-align: justify\">Apart from the PHP Arithmetic and String Operators, it also possess array operators which can be used to compare arrays effectively. A list of PHP Array operators has been listed in the Table 7.<\/p>\r\n&nbsp;\r\n<p style=\"text-align: center\"><img class=\"size-full wp-image-349 aligncenter\" src=\"http:\/\/csp12.epgpbooks.inflibnet.ac.in\/wp-content\/uploads\/sites\/60\/2018\/07\/Untitled-219.png\" alt=\"\" width=\"585\" height=\"421\" \/><\/p>\r\n\r\n<div>\r\n\r\n<strong>\u00a0 \u00a03.<\/strong>\u00a0\u00a0\u00a0 <strong>CONDITIONAL STATEMENTS<\/strong>\r\n\r\n&nbsp;\r\n<p style=\"text-align: justify\">Whenwe write code very often, we want to perform different actions based on various conditions. In those situations, we can use conditional statements in our code to handle.In PHP we have the following conditional statements to handle the situations which require various actions:<\/p>\r\n<p style=\"text-align: justify\"><\/p>\r\n<p style=\"text-align: justify\"><strong>if statement <\/strong>- executes some code if one condition is true<\/p>\r\n<p style=\"text-align: justify\"><\/p>\r\n<p style=\"text-align: justify\"><strong>if...else statement <\/strong>- executes some code if a condition is true and another code if that condition is false<\/p>\r\n<p style=\"text-align: justify\"><\/p>\r\n<p style=\"text-align: justify\"><strong>if...elseif....else statement <\/strong>- executes different codes for more than two conditions<strong> switch statement <\/strong>- selects one of the many blocks of code to be executed<\/p>\r\n<p style=\"text-align: justify\"><\/p>\r\n<p style=\"text-align: justify\"><strong>if Statement: i<\/strong>f statement is used to execute some code only if a specified condition is true.<\/p>\r\n&nbsp;\r\n\r\n<strong>Syntax<\/strong>\r\n\r\n&nbsp;\r\n\r\nif(condition){\r\n\r\n\/\/code to be executed\r\n\r\n}\r\n\r\n&nbsp;\r\n\r\n<strong>Example for if statement:<\/strong>\r\n\r\n&nbsp;\r\n\r\n&lt;?php\r\n\r\n$num=12;\r\n\r\nif($num&lt;100) { echo \"$num is less than 100\"; }\r\n\r\n?&gt;\r\n\r\n&nbsp;\r\n\r\n<strong>Output: <\/strong>12 is less than 100\r\n\r\n&nbsp;\r\n<p style=\"text-align: justify\"><strong>if...else Statement<\/strong>:The if....else statement executes some code if a condition is true and another code if that condition is false.<\/p>\r\n&nbsp;\r\n\r\n<strong>Syntax<\/strong>\r\n\r\n<\/div>\r\n<span style=\"text-align: initial;font-size: 1em\">\u00a0 \u00a0if (condition) { code to be executed if condition is true; else { code to be executed if condition is false;}\u00a0<\/span><span style=\"text-align: initial;font-size: 1em\">}<\/span>\r\n\r\n&nbsp;\r\n\r\n<strong style=\"text-align: initial;font-size: 1em\">Example for if..else statement:<\/strong>\r\n<div>\r\n\r\n\u00a0 \u00a0 &lt;?php\r\n\r\n$t = date(\"H\");\r\n\r\nif ($t &lt; \"20\") { echo \"Have a good day!\"; }\r\n\r\nelse { echo \"Have a good night!\"; }\r\n\r\n<span style=\"font-size: 1em;text-align: initial\">?&gt;<\/span>\r\n\r\n<\/div>\r\n<div>\r\n\r\n<strong>\u00a0 \u00a0 Output: <\/strong>Have a good night!\r\n\r\n&nbsp;\r\n<p style=\"text-align: justify\"><strong>if...elseif....else Statement<\/strong>:The if....elseif...else statement executes different codes for more than two\u00a0 Conditions.<\/p>\r\n&nbsp;\r\n\r\n<strong>Syntax<\/strong>\r\n\r\n&nbsp;\r\n\r\nif (condition) {\r\n\r\ncode to be executed if this condition is true; } elseif (condition) {\r\n\r\ncode to be executed if this condition is true; }\r\n\r\nelse {\r\n\r\ncode to be executed if all conditions are false;}\r\n\r\n&nbsp;\r\n\r\n<strong>Example for if..elseif\u2026else statement:<\/strong>\r\n\r\n&nbsp;\r\n\r\n&lt;html&gt;\r\n\r\n&lt;body&gt;\r\n\r\n&lt;?php\r\n\r\n$d=date(\"D\");\r\n\r\nif ($d==\"Fri\")\r\n\r\necho \"Have a nice weekend!\";\r\n\r\nelseif ($d==\"Sun\")\r\n\r\necho \"Have a nice Sunday!\";\r\n\r\nelse\r\n\r\necho \"Have a nice day!\"; ?&gt;\r\n\r\n&lt;\/body&gt;\r\n\r\n&lt;\/html&gt;\r\n\r\n&nbsp;\r\n\r\n<strong>Output<\/strong>:\r\n\r\n&nbsp;\r\n\r\nThe following example output is \"Have a nice weekend!\"\r\n\r\nif the current day is Friday, and \"Have a nice Sunday!\"\r\n\r\nif the current day is Sunday.\r\n\r\nOtherwise it will output \"Have a nice day!\"\r\n\r\n&nbsp;\r\n\r\n<strong>Switch Statement:<\/strong>\r\n\r\n<\/div>\r\n<p style=\"text-align: justify\"><span style=\"text-align: initial;font-size: 1em\">\u00a0 Switch statement can be used in situations where we are forced to select one of many blocks of code to be executed.<\/span><\/p>\r\n\r\n<div>\r\n\r\n<strong>\u00a0 \u00a0Syntax for Switch statement in PHP:<\/strong>\r\n\r\n&nbsp;\r\n\r\nswitch (n) {\r\n\r\ncase label1:\r\n\r\ncode to be executed if n=label1;\r\n\r\nbreak;\r\n\r\ncase label2:\r\n\r\ncode to be executed if n=label2;\r\n\r\nbreak;...\r\n\r\ndefault:\r\n\r\ncode to be executed if n is different from all labels;\r\n\r\n}\r\n\r\n&nbsp;\r\n\r\n<strong>Example of switch Statement:<\/strong>\r\n\r\n&nbsp;\r\n\r\n&lt;?php\r\n\r\n$num=20;\r\n\r\nswitch($num){\r\n\r\ncase 10:\r\n\r\necho(\"number is equals to 10\");\r\n\r\nbreak;\r\n\r\ncase 20:\r\n\r\necho(\"number is equal to 20\");\r\n\r\nbreak;\r\n\r\ncase 30:\r\n\r\necho(\"number is equal to 30\");\r\n\r\nbreak;\r\n\r\ndefault:\r\n\r\necho(\"number is not equal to 10, 20 or 30\");\r\n\r\n} ?&gt;\r\n\r\nBased on the case values, corresponding echo statements would get executed.\r\n\r\n&nbsp;\r\n\r\n<strong>LOOP STATEMENTS:<\/strong>\r\n\r\n&nbsp;\r\n<p style=\"text-align: justify\">Loop statements in PHP are used to execute the same block of code until the given condition is satisfied. Very often when we write code, we want the same block of code to run a number of times. We can use looping statements in our code to perform this.In PHP we have the following types of looping statements:<\/p>\r\n\r\n<\/div>\r\n<strong style=\"text-align: initial;font-size: 1em\">\u00a0 \u00a0while <\/strong><span style=\"text-align: initial;font-size: 1em\">- loops through a block of code if and as long as a specified condition is\u00a0<\/span><span style=\"text-align: initial;font-size: 1em\">true.<\/span>\r\n\r\n&nbsp;\r\n<p style=\"text-align: justify\"><strong style=\"text-align: initial;font-size: 1em\">do...while <\/strong><span style=\"text-align: initial;font-size: 1em\">- loops through a block of code once, and then repeats the loop as long as a special condition is true.<\/span><\/p>\r\n&nbsp;\r\n<p style=\"text-align: justify\"><strong style=\"text-align: initial;font-size: 1em\">for - <\/strong><span style=\"text-align: initial;font-size: 1em\">loops through a block of code a specified number of times.<\/span><\/p>\r\n&nbsp;\r\n<p style=\"text-align: justify\"><strong style=\"text-align: initial;font-size: 1em\">foreach <\/strong><span style=\"text-align: initial;font-size: 1em\">- loops through a block of code for each element in an array.<\/span><\/p>\r\n&nbsp;\r\n<p style=\"text-align: justify\"><strong style=\"text-align: initial;font-size: 1em\">While Statement :<\/strong><span style=\"text-align: initial;font-size: 1em\">The while statement will execute a block of code if and as long as a condition is true.<\/span><\/p>\r\n&nbsp;\r\n<p style=\"text-align: justify\"><strong style=\"text-align: initial;font-size: 1em\">Syntax of While statement:<\/strong><\/p>\r\n\r\n<div>\r\n\r\n\u00a0 \u00a0 \u00a0while (condition)\r\n\r\ncode to be executed;\r\n\r\n&nbsp;\r\n\r\n<strong>Example of While statement:<\/strong>\r\n\r\n&nbsp;\r\n\r\n&lt;?php\r\n\r\n$i=1;\r\n\r\nwhile($i&lt;=5) {\r\n\r\necho \"The number is \" . $i . \"&lt;br \/&gt;\";\r\n\r\n$i++;\r\n\r\n} ?&gt;\r\n\r\n&nbsp;\r\n\r\n<strong>Output:<\/strong>\r\n\r\n&nbsp;\r\n\r\nThe number is 1 The number is 2 The number is 3 The number is 4\r\n\r\n&nbsp;\r\n<p style=\"text-align: justify\"><strong>do...while Loop Statement :<\/strong>The do...while loop will always execute the block of code once, it will then check the condition, and repeat the loop until the specified condition is true.<\/p>\r\n&nbsp;\r\n\r\n<strong>Syntax of do\u2026while statement:<\/strong>\r\n\r\n&nbsp;\r\n\r\ndo {\r\n\r\ncode to be executed;\r\n\r\n} while (condition is true);\r\n\r\n&nbsp;\r\n\r\n<strong>Example:<\/strong>\r\n\r\n&nbsp;\r\n\r\n&lt;?php\r\n\r\n$n=1;\r\n\r\ndo{\r\n\r\necho \"$n&lt;br\/&gt;\";\r\n\r\n$n++;\r\n\r\n}while($n&lt;=10); ?&gt;\r\n\r\n<\/div>\r\n<p style=\"text-align: justify\"><strong style=\"text-align: initial;font-size: 1em\">\u00a0 \u00a0for Loop Statement :<\/strong><span style=\"text-align: initial;font-size: 1em\">PHP for loop statement can be used to traverse a set of code for the specified number of times.It can be used only if the number of iterations is known, otherwise while loop has to be used.<\/span><\/p>\r\n\r\n<div>\r\n\r\n<strong>\u00a0 \u00a0 Syntax \u2013 for Loop statement:<\/strong>for(initialization; condition; increment\/decrement){ \/\/code to be executed\r\n\r\n}\r\n\r\n&nbsp;\r\n\r\n<strong>Example \u2013 for Loop statement:<\/strong>\r\n\r\n&nbsp;\r\n\r\n&lt;?php\r\n\r\nfor ($i = 1; $i &lt;= 10; $i++)\r\n\r\n{\r\n\r\necho $i;\r\n\r\n}\r\n\r\n?&gt;\r\n\r\n&nbsp;\r\n<p style=\"text-align: justify\"><strong>for each Loop Statement <\/strong>:The foreach loop works only on arrays, and is used to loop through each key\/value pair in an array.<\/p>\r\n&nbsp;\r\n\r\n<strong>Syntax:<\/strong>\r\n\r\n&nbsp;\r\n\r\nforeach ($array as $value) {\r\n\r\ncode to be executed;\r\n\r\n}\r\n\r\n&nbsp;\r\n\r\n<strong>Example- for each Loop Statement:<\/strong>\r\n\r\n&nbsp;\r\n\r\n&lt;?php\r\n\r\n$season=array(\"summer\",\"winter\",\"spring\",\"autumn\");\r\n\r\nforeach( $season as $arr )\r\n\r\n{\r\n\r\necho \"Season is: $arr&lt;br \/&gt;\";\r\n\r\n}\r\n\r\n?&gt;\r\n\r\n&nbsp;\r\n<p style=\"text-align: justify\"><strong>Break Statements: <\/strong>PHP break statement breaks the execution of current for, while, do-while, switch and for-each loop. If we use a break statement inside inner loop, it breaks the execution of inner loop only.<\/p>\r\n&nbsp;\r\n\r\n<strong>Syntax:<\/strong>\r\n\r\n&nbsp;\r\n\r\njump statement;\r\n\r\nbreak;\r\n\r\n<\/div>\r\n<div>\r\n\r\n<strong>\u00a0 Example for break statement:<\/strong>\r\n\r\n&nbsp;\r\n\r\n&lt;?php\r\n\r\nfor($i=1;$i&lt;=10;$i++){\r\n\r\necho \"$i&lt;br\/&gt;\";\r\n\r\nif($i==5){ break; }\r\n\r\n}\r\n\r\n?&gt;\r\n\r\n&nbsp;\r\n<p style=\"text-align: justify\"><strong>Continue Statements: <\/strong>The continue statement is used within looping structures to skip the rest of the current loop iteration and continue the execution at the point of condition evaluation and then it begins the next iteration.<\/p>\r\n&nbsp;\r\n\r\n<strong>Example:<\/strong>\r\n\r\n&nbsp;\r\n\r\n&lt;?php\r\n\r\n$array = array(1, 2, 3, 4, 5, 6, 7, 8, 9, 0);\r\n\r\nforeach( $array as $value )\r\n\r\n{\r\n\r\nif( $value == 3 )\r\n\r\ncontinue;\r\n\r\necho \"Value is $value &lt;br \/&gt;\";\r\n\r\n}\r\n\r\n?&gt;\r\n\r\n&nbsp;\r\n\r\n<strong>4.\u00a0\u00a0 PHP FUNCTIONS<\/strong>\r\n\r\n&nbsp;\r\n<p style=\"text-align: justify\">PHP function is a piece of code that can be reused many times. This can take input as an argument list and return values. There are thousands of built-in functions in PHP.In PHP, we can define Conditional function, Function within Function and Recursive function also.<\/p>\r\n&nbsp;\r\n\r\n<strong>4.1 User Defined Functions<\/strong>\r\n\r\n&nbsp;\r\n<p style=\"text-align: justify\">Besides the built-in PHP functions, we can create our own functions which are known as user defined functions. A function is a block of statements that can be used repeatedly in a program.A function will not execute immediately when a page loads but it will be executed when a function is invoked.A user defined function declaration starts with the word \"function\".<\/p>\r\n&nbsp;\r\n\r\n<strong>Syntax:<\/strong>\r\n\r\n&nbsp;\r\n\r\nfunction functionName()\r\n\r\n{\r\n\r\ncode to be executed;\r\n\r\n}\r\n\r\n&nbsp;\r\n\r\n<strong>Example:<\/strong>\r\n\r\n<\/div>\r\n<span style=\"text-align: initial;font-size: 1em\">\u00a0 \u00a0&lt;?php<\/span>\r\n\r\n<span style=\"text-align: initial;font-size: 1em\">functionsayHello()<\/span>\r\n\r\n<span style=\"text-align: initial;font-size: 1em\">{<\/span>\r\n\r\n<span style=\"text-align: initial;font-size: 1em\">E<\/span><span style=\"text-align: initial;font-size: 1em\">cho \"Hello PHP Function\";<\/span>\r\n\r\n<span style=\"text-align: initial;font-size: 1em\">}<\/span>\r\n\r\n<span style=\"text-align: initial;font-size: 1em\">sayHello();\/\/calling function<\/span>\r\n\r\n<span style=\"text-align: initial;font-size: 1em\">?&gt;<\/span>\r\n<div>\r\n\r\n<strong>\u00a0 \u00a0Output:<\/strong>Hello PHP Function\r\n\r\n&nbsp;\r\n\r\n<strong>Rules for defining a function:<\/strong>\r\n<p style=\"text-align: justify\">A valid function name starts with a letter or underscore, followed by any number of letters, numbers, or underscores.<\/p>\r\n&nbsp;\r\n\r\nIt can't be started with numbers or special symbols.\r\n\r\n&nbsp;\r\n<p style=\"text-align: justify\"><strong>PHP Function Arguments: <\/strong>Information may be passed to functions via the argument list, which is a comma-delimited list of expressions. The arguments are evaluated from left to right.PHP supports passing arguments to the functions using anyone of the types: pass by value (the default), passing by reference, and default argument values. Variable-length argument lists are also supported in PHP. The example given below passes a single argument to PHP function<\/p>\r\n&nbsp;\r\n\r\n&lt;?php\r\n\r\nfunctionsayHello($name){\r\n\r\necho \"Hello $name&lt;br\/&gt;\"; }\r\n\r\nsayHello(\"Vimal\");\u00a0 sayHello(\"John\");\r\n\r\n?&gt;\r\n\r\n&nbsp;\r\n<p style=\"text-align: justify\"><strong>PHP Call ByReference: <\/strong>In this method, the value passed to the function does not modify the actual value by default (call by value). But the value can be modified by passing value as a reference.By default, value passed to the function is call by value. To pass value as a reference, it is advised to use ampersand (&amp;) symbol before the argument name.<\/p>\r\n&nbsp;\r\n\r\n<strong>Example:<\/strong>\r\n\r\n&nbsp;\r\n\r\n&lt;?php\r\n\r\nfunction adder(&amp;$str2) {\r\n\r\n$str2 .= 'Call By Reference'; }\r\n\r\n$str = 'Hello '; adder($str);\u00a0 echo $str;\r\n\r\n?&gt;\r\n\r\n&nbsp;\r\n\r\n<strong>Output:<\/strong>Call By Reference\r\n\r\n<\/div>\r\n<p style=\"text-align: justify\"><strong style=\"text-align: initial;font-size: 1em\">\u00a0 \u00a0PHP Default Argument Value:<\/strong><span style=\"text-align: initial;font-size: 1em\">The following example shows how to use a default parameter. If we call the function setHeight() without arguments it takes the default value as argument.<\/span><\/p>\r\n\r\n<div>\r\n\r\n&nbsp;\r\n\r\n<strong>Example:<\/strong>\r\n\r\n&nbsp;\r\n\r\n&lt;?php\r\n\r\nfunctionsetHeight($minheight = 50) {\r\n\r\necho \"The height is : $minheight&lt;br&gt;\";\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 }\r\n\r\nsetHeight(350);\r\n\r\nsetHeight(); \/\/ will use the default value of 50\r\n\r\nsetHeight(135);\r\n\r\n?&gt;\r\n\r\n&nbsp;\r\n<p style=\"text-align: justify\"><strong>PHP Functions - Returning values: <\/strong>Apart from the functions defined above, functions can also be defined and used to return values.<\/p>\r\n&nbsp;\r\n\r\n<strong>Example:<\/strong>\r\n\r\n&nbsp;\r\n\r\n&lt;?php\r\n\r\nfunction add($x,$y)\r\n\r\n{\r\n\r\n$total = $x + $y;\r\n\r\nreturn $total;\r\n\r\n}\r\n\r\necho \"1 + 16 = \" . add(1,16);\r\n\r\n?&gt;\r\n\r\n&nbsp;\r\n\r\n<strong>Output: <\/strong>1 + 16 = 17\r\n\r\n&nbsp;\r\n<p style=\"text-align: justify\"><strong>PHP Call By Value: <\/strong>PHP allows the user to call function by value and reference both.In case of PHP call by value, actual value does not get altered, if it is modified inside the function.<\/p>\r\n&nbsp;\r\n\r\n<strong>Example:<\/strong>\r\n\r\n&nbsp;\r\n\r\n&lt;?php\r\n\r\nfunction adder($str2) {\r\n\r\n$str2 .= 'Call By Value';\r\n\r\n}\r\n\r\n$str = 'Hello ';\r\n\r\nadder($str);\r\n\r\necho $str;\r\n\r\n?&gt;\r\n\r\n&nbsp;\r\n\r\n<strong>Output:<\/strong>Hello\r\n\r\n<\/div>\r\n<p style=\"text-align: justify\"><strong style=\"text-align: initial;font-size: 1em\">\u00a0 PHP Variable Length Argument Function: <\/strong><span style=\"text-align: initial;font-size: 1em\">PHP supports the concept of variable length argument functions. This means that if a variable name has parentheses appended to it, PHP will look for a function with the same name as whatever the variable evaluates to, and will attempt to execute it. Among other things, this can be used to implement callbacks, function tables, and so forth.Variable functions won't work with language constructs such as echo, print, unset(), isset(), empty(), include, require and the like. Wrapper functions can be utilized to make use of any of these constructs as variable functions.<\/span><\/p>\r\n\r\n<div>\r\n\r\n&nbsp;\r\n\r\n<strong>Variable length argument function example:<\/strong>\r\n\r\n&nbsp;\r\n\r\n&lt;?php\r\n\r\nfunction foo() {\r\n\r\necho \"In foo()&lt;br \/&gt;\\n\";\r\n\r\n}\r\n\r\nfunction bar($arg = '') {\r\n\r\necho \"In bar(); argument was '$arg'.&lt;br \/&gt;\\n\"; }\r\n\r\n\/\/\u00a0 This is a wrapper function around echo functionechoit($string) { echo $string; } $func = 'foo';\r\n\r\n$func();\u00a0 \/\/ This calls foo()\r\n\r\n$func = 'bar';\r\n\r\n$func('test'); \/\/ This calls bar()\r\n\r\n$func = 'echoit';\r\n\r\n$func('test'); \/\/ This calls echoit()\r\n\r\n?&gt;\r\n\r\n&nbsp;\r\n\r\n<strong>Advantage of using PHP Functions:<\/strong>\r\n\r\n&nbsp;\r\n\r\nCode Reusability Less Code\r\n\r\nEasy to understand.\r\n\r\n&nbsp;\r\n\r\n<strong>5.\u00a0\u00a0<\/strong><strong>PHP ARRAYS<\/strong>\r\n\r\n&nbsp;\r\n<p style=\"text-align: justify\">An array stores multiple values in one single variable.Arrays have names that begin with $.PHP array is an ordered map (contains value on the basis of key) which is used to hold multiple values of similar type in a single variable. The element type is not specified and it can mix the data types too.Suppose we need to store roll numbers of 100 students then we can use array variable roll which can store 100 values in single variable with index.<\/p>\r\n&nbsp;\r\n\r\n<strong>Example:<\/strong>\r\n\r\n<\/div>\r\n<p style=\"text-align: justify\"><span style=\"text-align: initial;font-size: 1em\">Create an Array in PHPusing the array() language construct. It takes any number of comma-separated key =&gt; value pairs as arguments.<\/span><\/p>\r\n\r\n<div>\r\n\r\n<strong>\u00a0 \u00a0 Syntax:<\/strong>array();\r\n\r\narray(key =&gt; value, key2 =&gt; value2, key3 =&gt; value3, ...);\r\n\r\n<strong>Example:<\/strong>$shapes = array(\"square\",\"rectangle\",\"circle\",\"oval\");\r\n\r\n&nbsp;\r\n\r\n<strong>PHP Array Types<\/strong>\r\n\r\n&nbsp;\r\n\r\nThere are 3 types of array in PHP.\r\n<ul>\r\n \t<li style=\"text-align: justify\"><strong>Indexed Array <\/strong>- An array with a numeric index<\/li>\r\n \t<li style=\"text-align: justify\"><strong>Associative Array <\/strong>- An array with strings as index. This stores element values in association with key values rather than in a linear index order.<\/li>\r\n \t<li style=\"text-align: justify\"><strong>Multidimensional Array - <\/strong>An array containing one or more arrays<\/li>\r\n<\/ul>\r\n<p style=\"text-align: justify\"><strong>PHP Indexed Arrays:<\/strong>PHP index is represented by number which starts from 0. We can store number, string and objects in the PHP array. All PHP array elements are assigned to an index number by default. There are two ways to create indexed arrays where the index can be assigned automatically (index always starts at 0),like this:<\/p>\r\n&nbsp;\r\n\r\n<strong>Type 1<\/strong><strong>:<\/strong>$season=array(\"summer\",\"winter\",\"spring\",\"autumn\");\r\n\r\n&nbsp;\r\n\r\n<strong>Type 2<\/strong><strong>:<\/strong>$season[0]=\"summer\";\r\n\r\n$season[1]=\"winter\";\r\n\r\n$season[2]=\"spring\";\r\n\r\n$season[3]=\"autumn\";\r\n\r\n&nbsp;\r\n\r\n<strong>PHP Indexed Arrays Examples:<\/strong>\r\n\r\n&nbsp;\r\n\r\n<strong>Example 1:<\/strong>\r\n\r\n&nbsp;\r\n\r\n&lt;?php\r\n\r\n$cars = array(\"Volvo\", \"BMW\", \"Toyota\");\r\n\r\necho \"I like \" . $cars[0] . \", \" . $cars[1] . \" and \" . $cars[2] . \".\"; ?&gt;\r\n\r\n&nbsp;\r\n\r\n<strong>Example 2:<\/strong>\r\n\r\n<\/div>\r\n<span style=\"text-align: initial;font-size: 1em\">\u00a0 \u00a0 &lt;?php<\/span>\r\n\r\n<span style=\"text-align: initial;font-size: 1em\">$size[0]=\"Big\";<\/span>\r\n\r\n<span style=\"text-align: initial;font-size: 1em\">$size[1]=\"Medium\";<\/span>\r\n\r\n<span style=\"text-align: initial;font-size: 1em\">$size[2]=\"Short\";<\/span>\r\n\r\n<span style=\"text-align: initial;font-size: 1em\">echo \"Size: $size[0], $size[1] and $size[2]\"; ?&gt;<\/span>\r\n\r\n&nbsp;\r\n<div>\r\n<p style=\"text-align: justify\"><strong>PHP Associative Array:<\/strong>The associative arrays are very similar to numeric arrays in term of functionality but they are different in terms of their index.Associative array will have their index as string so that we can establish a strong association between key and values.There are two ways to create an associative array:<\/p>\r\n&nbsp;\r\n\r\n$age = array(\"Peter\"=&gt;\"35\", \"Ben\"=&gt;\"37\", \"Joe\"=&gt;\"43\");\r\n\r\n(Or)\r\n\r\n$age['Peter'] = \"35\";\r\n\r\n$age['Ben'] = \"37\";\r\n\r\n$age['Joe'] = \"43\";\r\n\r\n&nbsp;\r\n\r\n<strong>Example of PHP Associative Arrays<\/strong>\r\n\r\n&nbsp;\r\n\r\n&lt;?php\u00a0\u00a0\u00a0\u00a0\u00a0 \/* First method to associate create array. *\/\r\n\r\n$salaries = array(\"Kumar\" =&gt; 2000, \"Bala\" =&gt; 1000, \"Sudharsan\" =&gt; 500);\r\n\r\necho \"Salary of Kumar is \". $salaries['Kumar'] . \"&lt;br \/&gt;\"; echo \"Salary of Bala is \". $salaries['Bala']. \"&lt;br \/&gt;\";\r\n\r\necho \"Salary of Sudharsan is \". $salaries['Sudharsan']. \"&lt;br \/&gt;\";\r\n\r\n\/* Second method to create array. *\/\r\n\r\n$salaries['Kumar'] = \"high\";\r\n\r\n$salaries['Bala'] = \"medium\";\r\n\r\n$salaries['Sudharsan'] = \"low\";\r\n\r\necho \"Salary of Kumar is \". $salaries['Kumar'] . \"&lt;br \/&gt;\";\r\n\r\n<span style=\"text-align: initial;font-size: 1em\">echo \"Salary of Bala is \". $salaries['Bala']. \"&lt;br \/&gt;\";<\/span>\r\n\r\n<span style=\"text-align: initial;font-size: 1em\">echo \"Salary of Sudharsan is \". $salaries['Sudharsan']. \"&lt;br \/&gt;\"; ?&gt;<\/span>\r\n\r\n<\/div>\r\n<div>\r\n\r\n<strong>\u00a0 \u00a0 Output<\/strong>\r\n\r\n&nbsp;\r\n\r\nSalary of Kumar is 2000\r\n\r\nSalary of Bala is 1000\r\n\r\nSalary of Sudharsan is 500\r\n\r\nSalary of Kumar is high\r\n\r\nSalary of Bala is medium\r\n\r\nSalary of Sudharsan is low\r\n\r\n&nbsp;\r\n<p style=\"text-align: justify\"><strong>PHP Multidimensional Arrays:<\/strong>PHP multidimensional array is otherwise known as array of arrays. It allows the user to store tabular data in an array. PHP multidimensional array can be represented in the form of matrix which is represented by row * column.<\/p>\r\n&nbsp;\r\n\r\n<strong>Multidimensional array Example:<\/strong>\r\n\r\n&nbsp;\r\n\r\n$emp = array\r\n\r\n(\r\n\r\narray(1,\u201csachin\",400000),\r\n\r\narray(2,\"john\",500000),\r\n\r\narray(3,\"rahul\",300000)\r\n\r\n);\r\n\r\nA simple example of PHP multidimensional array is given below:\r\n\r\nExample of PHP Multidimensional Array:\r\n\r\n&lt;?php\r\n\r\n$marks = array(\r\n\r\n\"Sachin\" =&gt; array (\r\n\r\n\"physics\" =&gt; 35,\r\n\r\n\"maths\" =&gt; 30,\r\n\r\n\"chemistry\" =&gt; 39\r\n\r\n),\r\n\r\n<span style=\"font-size: 1em;text-align: initial\">\"Raju\" =&gt; array (<\/span>\r\n\r\n<span style=\"text-align: initial;font-size: 1em\">\"physics\" =&gt; 30,<\/span>\r\n\r\n<span style=\"text-align: initial;font-size: 1em\">\"maths\" =&gt; 32,<\/span>\r\n\r\n<span style=\"text-align: initial;font-size: 1em\">\"chemistry\" =&gt; 29<\/span>\r\n\r\n<span style=\"text-align: initial;font-size: 1em\">),<\/span>\r\n\r\n<span style=\"text-align: initial;font-size: 1em\">\"Venkat\" =&gt; array (<\/span>\r\n\r\n<span style=\"text-align: initial;font-size: 1em\">\"physics\" =&gt; 31,<\/span>\r\n\r\n<span style=\"text-align: initial;font-size: 1em\">\"maths\" =&gt; 22,<\/span>\r\n\r\n<span style=\"text-align: initial;font-size: 1em\">\"chemistry\" =&gt; 39<\/span>\r\n\r\n<span style=\"text-align: initial;font-size: 1em\">)<\/span>\r\n\r\n<span style=\"text-align: initial;font-size: 1em\">);<\/span>\r\n\r\n<span style=\"text-align: initial;font-size: 1em\">\/* Accessing multi-dimensional array values *\/<\/span>\r\n\r\n<span style=\"text-align: initial;font-size: 1em\">echo \"Marks for Sachin in physics : \" ;<\/span>\r\n\r\n<span style=\"text-align: initial;font-size: 1em\">E<\/span><span style=\"text-align: initial;font-size: 1em\">cho $marks['Sachin']['physics'] . \"&lt;br \/&gt;\";<\/span>\r\n\r\n<span style=\"text-align: initial;font-size: 1em\">echo \"Marks for Raju in maths : \";<\/span>\r\n\r\n<span style=\"text-align: initial;font-size: 1em\">echo $marks['Raju']['maths'] . \"&lt;br \/&gt;\";<\/span>\r\n\r\n<span style=\"text-align: initial;font-size: 1em\">echo \"Marks for Venkat in chemistry : \" ;<\/span>\r\n\r\n<span style=\"text-align: initial;font-size: 1em\">echo $marks['Venkat']['chemistry'] . \"&lt;br \/&gt;\";<\/span><span style=\"text-align: initial;font-size: 1em\">?&gt;<\/span>\r\n\r\n<\/div>\r\n<div>\r\n\r\n<strong>\u00a0 \u00a0Output for Multidimensional Arrays:<\/strong>\r\n\r\n&nbsp;\r\n\r\nMarks for Sachin in physics : 35\r\n\r\nMarks for Raju in maths : 32\r\n\r\nMarks for Venkat in chemistry : 39\r\n\r\n&nbsp;\r\n\r\n<strong>Advantages of PHP Array<\/strong>\r\n\r\n&nbsp;\r\n\r\n<strong>Lesser amount of Code:<\/strong>There is no need to define multiple variables.\r\n\r\n&nbsp;\r\n<p style=\"text-align: justify\"><strong>Easy to traverse: <\/strong>By the help of single loop, we can traverse all the elements of an array easily and quickly.<\/p>\r\n&nbsp;\r\n\r\n<strong>Sorting: <\/strong>We can sort the elements of array easily.\r\n\r\n<\/div>\r\n<p style=\"text-align: justify\">\u00a0 Previous module has discussed the deployment of PHP programs in XAMPP\/ WAMPP server. PHP scripts can be easily written using the syntax, operators, statements, functions, strings and arrays discussed in this module and deployed in XAMPP\/ WAMPP server for the successful execution of web pages.<\/p>\r\n&nbsp;\r\n\r\n<strong>Summary<\/strong>\r\n\r\n&nbsp;\r\n<p style=\"text-align: justify\">This module is intended to discuss about the various operators available in PHP along with the strings applicable in this script. Also, the various types of conditional statements have been discussed with examples. Usage of PHP Arrays and Functions with various types applicable on it has been visited with suitable examples for successful creation and deployment of web pages in web server.<\/p>\r\n&nbsp;\r\n\r\n<strong>Web Links<\/strong>\r\n<ul>\r\n \t<li><a href=\"https:\/\/www.w3schools.com\/php\/\">https:\/\/www.w3schools.com\/php\/<\/a><\/li>\r\n \t<li><a href=\"http:\/\/www.c4learn.com\/php\/php-continue-statement\/\">http:\/\/www.c4learn.com\/php\/php-continue-statement\/<\/a><\/li>\r\n \t<li><a href=\"http:\/\/www.webstepbook.com\/supplements.shtml\">http:\/\/www.webstepbook.com\/supplements.shtml<\/a><\/li>\r\n \t<li><a href=\"http:\/\/sg2.php.net\/manual\/en\/\">http:\/\/sg2.php.net\/manual\/en\/<\/a><\/li>\r\n \t<li><a href=\"http:\/\/www.javatpoint.com\/php-tutorial\">http:\/\/www.javatpoint.com\/php-tutorial<\/a><\/li>\r\n \t<li><a href=\"http:\/\/www.w3schools.com\/php\/default.asp\">http:\/\/www.w3schools.com\/php\/default.asp<\/a><\/li>\r\n \t<li><a href=\"https:\/\/github.com\/linghangedu\/PHP-Primer\">https:\/\/github.com\/linghangedu\/PHP-Primer<\/a><\/li>\r\n \t<li><a href=\"https:\/\/www.javatpoint.com\/php-tutorial\">https:\/\/www.javatpoint.com\/php-tutorial<\/a><\/li>\r\n \t<li><a href=\"http:\/\/www.php.net\/\">http:\/\/www.php.net\/<\/a><\/li>\r\n \t<li>Steven Holzner, \u201c PHP: The Complete Reference\u201d, First Edition, McGraw-Hill Education,2007.<\/li>\r\n \t<li>Deitel and Deitel, \u201c Internet and World Wide Web: How to Program\u201d, Fifth Edition, Pearson Education, 2012.<\/li>\r\n \t<li>David Sklar and Adam Trachtenberg, \u201cPHP Cookbook\u201d, 3rd Edition, O\u2019Reilly Media, 2014<\/li>\r\n<\/ul>","rendered":"<div>\n<p><strong>\u00a0 Learning Objectives<\/strong><\/p>\n<p>&nbsp;<\/p>\n<p style=\"text-align: justify\">This module is intended to learn about the PHP Strings, usage of various PHP operators, different types of PHP functions and PHP Arrays for successful PHP scripts programming and deployment in Web server.<\/p>\n<p>&nbsp;<\/p>\n<p><strong>1.<\/strong>\u00a0\u00a0\u00a0 <strong>PHP String<\/strong><\/p>\n<p>&nbsp;<\/p>\n<p style=\"text-align: justify\">A string is series of characters, where a character is the same as a byte. This means that PHP only supports a 256-character set, and hence does not offer native Unicode support.<\/p>\n<p>&nbsp;<\/p>\n<p><strong>2.\u00a0\u00a0 PHP Operators<\/strong><\/p>\n<p>&nbsp;<\/p>\n<p>PHP operator is a symbol that is used to perform operations on various operands. For example:<\/p>\n<p style=\"text-align: justify\">$num=10+20;\/\/+ is the operator and 10, 20 are operands.In the above example, + is the binary operator, 10 and 20 are operands and $num is a variable.Operators are used to perform operations on variables and values.Operators in PHP are similar to those found in many modern C-like programming languages.PHP divides the available set of operators in the following groups:<\/p>\n<p>Arithmetic operators Assignment operators Comparison operators<\/p>\n<p>Increment\/Decrement operators Logical operators<\/p>\n<p>String operators Array operators<\/p>\n<p style=\"text-align: justify\">We can also categorize operators on behalf of operands. Using Operators, they can be categorized in 3 forms:<\/p>\n<p>&nbsp;<\/p>\n<p><strong>Unary Operators: <\/strong>works on single operands such as ++, &#8212; etc.<\/p>\n<p><strong style=\"text-align: initial;font-size: 1em\">Binary Operators: <\/strong><span style=\"text-align: initial;font-size: 1em\">works on two operands such as binary +, -, *, \/ etc.<\/span><\/p>\n<p><strong style=\"text-align: initial;font-size: 1em\">Ternary Operators: <\/strong><span style=\"text-align: initial;font-size: 1em\">works on three operands such as &#8220;?:&#8221;.<\/span><\/p>\n<p>&nbsp;<\/p>\n<p><strong style=\"text-align: initial;font-size: 1em\">2.1 PHP Arithmetic Operators<\/strong><\/p>\n<\/div>\n<p style=\"text-align: justify\">\u00a0 The PHP arithmetic operators are used along with numerical values to perform common arithmetical operations, such as addition, subtraction, multiplication and divisionas shown in Table 1.<\/p>\n<p>&nbsp;<\/p>\n<p style=\"text-align: center\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-342 aligncenter\" src=\"http:\/\/csp12.epgpbooks.inflibnet.ac.in\/wp-content\/uploads\/sites\/60\/2018\/07\/Untitled-212.png\" alt=\"\" width=\"626\" height=\"288\" srcset=\"https:\/\/ebooks.inflibnet.ac.in\/csp12\/wp-content\/uploads\/sites\/60\/2018\/07\/Untitled-212.png 626w, https:\/\/ebooks.inflibnet.ac.in\/csp12\/wp-content\/uploads\/sites\/60\/2018\/07\/Untitled-212-300x138.png 300w, https:\/\/ebooks.inflibnet.ac.in\/csp12\/wp-content\/uploads\/sites\/60\/2018\/07\/Untitled-212-65x30.png 65w, https:\/\/ebooks.inflibnet.ac.in\/csp12\/wp-content\/uploads\/sites\/60\/2018\/07\/Untitled-212-225x104.png 225w, https:\/\/ebooks.inflibnet.ac.in\/csp12\/wp-content\/uploads\/sites\/60\/2018\/07\/Untitled-212-350x161.png 350w\" sizes=\"auto, (max-width: 626px) 100vw, 626px\" \/><\/p>\n<p>&nbsp;<\/p>\n<p><strong>2.2 PHP Assignment Operators<\/strong><\/p>\n<p>&nbsp;<\/p>\n<p style=\"text-align: justify\">The PHP assignment operators are used along with numerical values to assign a value to a variable.The basic assignment operator in PHP is &#8220;=&#8221;. Different Assignment operators available in PHP script is shown in Table 2.<\/p>\n<p>&nbsp;<\/p>\n<p style=\"text-align: center\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-343 aligncenter\" src=\"http:\/\/csp12.epgpbooks.inflibnet.ac.in\/wp-content\/uploads\/sites\/60\/2018\/07\/Untitled-213.png\" alt=\"\" width=\"498\" height=\"272\" srcset=\"https:\/\/ebooks.inflibnet.ac.in\/csp12\/wp-content\/uploads\/sites\/60\/2018\/07\/Untitled-213.png 498w, https:\/\/ebooks.inflibnet.ac.in\/csp12\/wp-content\/uploads\/sites\/60\/2018\/07\/Untitled-213-300x164.png 300w, https:\/\/ebooks.inflibnet.ac.in\/csp12\/wp-content\/uploads\/sites\/60\/2018\/07\/Untitled-213-65x36.png 65w, https:\/\/ebooks.inflibnet.ac.in\/csp12\/wp-content\/uploads\/sites\/60\/2018\/07\/Untitled-213-225x123.png 225w, https:\/\/ebooks.inflibnet.ac.in\/csp12\/wp-content\/uploads\/sites\/60\/2018\/07\/Untitled-213-350x191.png 350w\" sizes=\"auto, (max-width: 498px) 100vw, 498px\" \/><\/p>\n<p style=\"text-align: center\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-344 aligncenter\" src=\"http:\/\/csp12.epgpbooks.inflibnet.ac.in\/wp-content\/uploads\/sites\/60\/2018\/07\/Untitled-214.png\" alt=\"\" width=\"482\" height=\"169\" srcset=\"https:\/\/ebooks.inflibnet.ac.in\/csp12\/wp-content\/uploads\/sites\/60\/2018\/07\/Untitled-214.png 482w, https:\/\/ebooks.inflibnet.ac.in\/csp12\/wp-content\/uploads\/sites\/60\/2018\/07\/Untitled-214-300x105.png 300w, https:\/\/ebooks.inflibnet.ac.in\/csp12\/wp-content\/uploads\/sites\/60\/2018\/07\/Untitled-214-65x23.png 65w, https:\/\/ebooks.inflibnet.ac.in\/csp12\/wp-content\/uploads\/sites\/60\/2018\/07\/Untitled-214-225x79.png 225w, https:\/\/ebooks.inflibnet.ac.in\/csp12\/wp-content\/uploads\/sites\/60\/2018\/07\/Untitled-214-350x123.png 350w\" sizes=\"auto, (max-width: 482px) 100vw, 482px\" \/><\/p>\n<p>&nbsp;<\/p>\n<p><strong>2.3 PHP Comparison Operators<\/strong><\/p>\n<p>&nbsp;<\/p>\n<p style=\"text-align: justify\">The PHP comparison operators are used to compare two values (number or string) as shown in Table 3.<\/p>\n<p>&nbsp;<\/p>\n<p style=\"text-align: center\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-345 aligncenter\" src=\"http:\/\/csp12.epgpbooks.inflibnet.ac.in\/wp-content\/uploads\/sites\/60\/2018\/07\/Untitled-215.png\" alt=\"\" width=\"560\" height=\"487\" srcset=\"https:\/\/ebooks.inflibnet.ac.in\/csp12\/wp-content\/uploads\/sites\/60\/2018\/07\/Untitled-215.png 560w, https:\/\/ebooks.inflibnet.ac.in\/csp12\/wp-content\/uploads\/sites\/60\/2018\/07\/Untitled-215-300x261.png 300w, https:\/\/ebooks.inflibnet.ac.in\/csp12\/wp-content\/uploads\/sites\/60\/2018\/07\/Untitled-215-65x57.png 65w, https:\/\/ebooks.inflibnet.ac.in\/csp12\/wp-content\/uploads\/sites\/60\/2018\/07\/Untitled-215-225x196.png 225w, https:\/\/ebooks.inflibnet.ac.in\/csp12\/wp-content\/uploads\/sites\/60\/2018\/07\/Untitled-215-350x304.png 350w\" sizes=\"auto, (max-width: 560px) 100vw, 560px\" \/><\/p>\n<p>&nbsp;<\/p>\n<p><strong>2.4 PHP Increment \/ Decrement Operators<\/strong><\/p>\n<p>&nbsp;<\/p>\n<p style=\"text-align: justify\">The PHP increment\/decrement operators are used to increment\/decrement the value of the variable as shown in Table 4.<\/p>\n<p>&nbsp;<\/p>\n<p style=\"text-align: center\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-346 aligncenter\" src=\"http:\/\/csp12.epgpbooks.inflibnet.ac.in\/wp-content\/uploads\/sites\/60\/2018\/07\/Untitled-216.png\" alt=\"\" width=\"509\" height=\"204\" srcset=\"https:\/\/ebooks.inflibnet.ac.in\/csp12\/wp-content\/uploads\/sites\/60\/2018\/07\/Untitled-216.png 509w, https:\/\/ebooks.inflibnet.ac.in\/csp12\/wp-content\/uploads\/sites\/60\/2018\/07\/Untitled-216-300x120.png 300w, https:\/\/ebooks.inflibnet.ac.in\/csp12\/wp-content\/uploads\/sites\/60\/2018\/07\/Untitled-216-65x26.png 65w, https:\/\/ebooks.inflibnet.ac.in\/csp12\/wp-content\/uploads\/sites\/60\/2018\/07\/Untitled-216-225x90.png 225w, https:\/\/ebooks.inflibnet.ac.in\/csp12\/wp-content\/uploads\/sites\/60\/2018\/07\/Untitled-216-350x140.png 350w\" sizes=\"auto, (max-width: 509px) 100vw, 509px\" \/><\/p>\n<p>&nbsp;<\/p>\n<p><strong>2.5 PHP Logical Operators<\/strong><\/p>\n<p>&nbsp;<\/p>\n<p>The PHP logical operators are used to combine conditional statements as shown in Table 5.<\/p>\n<p>&nbsp;<\/p>\n<p style=\"text-align: center\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-347 aligncenter\" src=\"http:\/\/csp12.epgpbooks.inflibnet.ac.in\/wp-content\/uploads\/sites\/60\/2018\/07\/Untitled-217.png\" alt=\"\" width=\"572\" height=\"349\" srcset=\"https:\/\/ebooks.inflibnet.ac.in\/csp12\/wp-content\/uploads\/sites\/60\/2018\/07\/Untitled-217.png 572w, https:\/\/ebooks.inflibnet.ac.in\/csp12\/wp-content\/uploads\/sites\/60\/2018\/07\/Untitled-217-300x183.png 300w, https:\/\/ebooks.inflibnet.ac.in\/csp12\/wp-content\/uploads\/sites\/60\/2018\/07\/Untitled-217-65x40.png 65w, https:\/\/ebooks.inflibnet.ac.in\/csp12\/wp-content\/uploads\/sites\/60\/2018\/07\/Untitled-217-225x137.png 225w, https:\/\/ebooks.inflibnet.ac.in\/csp12\/wp-content\/uploads\/sites\/60\/2018\/07\/Untitled-217-350x214.png 350w\" sizes=\"auto, (max-width: 572px) 100vw, 572px\" \/><\/p>\n<p>&nbsp;<\/p>\n<p><strong>2.6 PHP String Operators<\/strong><\/p>\n<p>&nbsp;<\/p>\n<p style=\"text-align: justify\">PHP has two operators that are specially designed to perform operations on strings as shown in Table 6.<\/p>\n<p>&nbsp;<\/p>\n<p style=\"text-align: center\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-348 aligncenter\" src=\"http:\/\/csp12.epgpbooks.inflibnet.ac.in\/wp-content\/uploads\/sites\/60\/2018\/07\/Untitled-218.png\" alt=\"\" width=\"526\" height=\"258\" srcset=\"https:\/\/ebooks.inflibnet.ac.in\/csp12\/wp-content\/uploads\/sites\/60\/2018\/07\/Untitled-218.png 526w, https:\/\/ebooks.inflibnet.ac.in\/csp12\/wp-content\/uploads\/sites\/60\/2018\/07\/Untitled-218-300x147.png 300w, https:\/\/ebooks.inflibnet.ac.in\/csp12\/wp-content\/uploads\/sites\/60\/2018\/07\/Untitled-218-65x32.png 65w, https:\/\/ebooks.inflibnet.ac.in\/csp12\/wp-content\/uploads\/sites\/60\/2018\/07\/Untitled-218-225x110.png 225w, https:\/\/ebooks.inflibnet.ac.in\/csp12\/wp-content\/uploads\/sites\/60\/2018\/07\/Untitled-218-350x172.png 350w\" sizes=\"auto, (max-width: 526px) 100vw, 526px\" \/><\/p>\n<p>&nbsp;<\/p>\n<p><strong>2.7 PHP Array Operators<\/strong><\/p>\n<p>&nbsp;<\/p>\n<p style=\"text-align: justify\">Apart from the PHP Arithmetic and String Operators, it also possess array operators which can be used to compare arrays effectively. A list of PHP Array operators has been listed in the Table 7.<\/p>\n<p>&nbsp;<\/p>\n<p style=\"text-align: center\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-349 aligncenter\" src=\"http:\/\/csp12.epgpbooks.inflibnet.ac.in\/wp-content\/uploads\/sites\/60\/2018\/07\/Untitled-219.png\" alt=\"\" width=\"585\" height=\"421\" srcset=\"https:\/\/ebooks.inflibnet.ac.in\/csp12\/wp-content\/uploads\/sites\/60\/2018\/07\/Untitled-219.png 585w, https:\/\/ebooks.inflibnet.ac.in\/csp12\/wp-content\/uploads\/sites\/60\/2018\/07\/Untitled-219-300x216.png 300w, https:\/\/ebooks.inflibnet.ac.in\/csp12\/wp-content\/uploads\/sites\/60\/2018\/07\/Untitled-219-65x47.png 65w, https:\/\/ebooks.inflibnet.ac.in\/csp12\/wp-content\/uploads\/sites\/60\/2018\/07\/Untitled-219-225x162.png 225w, https:\/\/ebooks.inflibnet.ac.in\/csp12\/wp-content\/uploads\/sites\/60\/2018\/07\/Untitled-219-350x252.png 350w\" sizes=\"auto, (max-width: 585px) 100vw, 585px\" \/><\/p>\n<div>\n<p><strong>\u00a0 \u00a03.<\/strong>\u00a0\u00a0\u00a0 <strong>CONDITIONAL STATEMENTS<\/strong><\/p>\n<p>&nbsp;<\/p>\n<p style=\"text-align: justify\">Whenwe write code very often, we want to perform different actions based on various conditions. In those situations, we can use conditional statements in our code to handle.In PHP we have the following conditional statements to handle the situations which require various actions:<\/p>\n<p style=\"text-align: justify\">\n<p style=\"text-align: justify\"><strong>if statement <\/strong>&#8211; executes some code if one condition is true<\/p>\n<p style=\"text-align: justify\">\n<p style=\"text-align: justify\"><strong>if&#8230;else statement <\/strong>&#8211; executes some code if a condition is true and another code if that condition is false<\/p>\n<p style=\"text-align: justify\">\n<p style=\"text-align: justify\"><strong>if&#8230;elseif&#8230;.else statement <\/strong>&#8211; executes different codes for more than two conditions<strong> switch statement <\/strong>&#8211; selects one of the many blocks of code to be executed<\/p>\n<p style=\"text-align: justify\">\n<p style=\"text-align: justify\"><strong>if Statement: i<\/strong>f statement is used to execute some code only if a specified condition is true.<\/p>\n<p>&nbsp;<\/p>\n<p><strong>Syntax<\/strong><\/p>\n<p>&nbsp;<\/p>\n<p>if(condition){<\/p>\n<p>\/\/code to be executed<\/p>\n<p>}<\/p>\n<p>&nbsp;<\/p>\n<p><strong>Example for if statement:<\/strong><\/p>\n<p>&nbsp;<\/p>\n<p>&lt;?php<\/p>\n<p>$num=12;<\/p>\n<p>if($num&lt;100) { echo &#8220;$num is less than 100&#8221;; }<\/p>\n<p>?&gt;<\/p>\n<p>&nbsp;<\/p>\n<p><strong>Output: <\/strong>12 is less than 100<\/p>\n<p>&nbsp;<\/p>\n<p style=\"text-align: justify\"><strong>if&#8230;else Statement<\/strong>:The if&#8230;.else statement executes some code if a condition is true and another code if that condition is false.<\/p>\n<p>&nbsp;<\/p>\n<p><strong>Syntax<\/strong><\/p>\n<\/div>\n<p><span style=\"text-align: initial;font-size: 1em\">\u00a0 \u00a0if (condition) { code to be executed if condition is true; else { code to be executed if condition is false;}\u00a0<\/span><span style=\"text-align: initial;font-size: 1em\">}<\/span><\/p>\n<p>&nbsp;<\/p>\n<p><strong style=\"text-align: initial;font-size: 1em\">Example for if..else statement:<\/strong><\/p>\n<div>\n<p>\u00a0 \u00a0 &lt;?php<\/p>\n<p>$t = date(&#8220;H&#8221;);<\/p>\n<p>if ($t &lt; &#8220;20&#8221;) { echo &#8220;Have a good day!&#8221;; }<\/p>\n<p>else { echo &#8220;Have a good night!&#8221;; }<\/p>\n<p><span style=\"font-size: 1em;text-align: initial\">?&gt;<\/span><\/p>\n<\/div>\n<div>\n<p><strong>\u00a0 \u00a0 Output: <\/strong>Have a good night!<\/p>\n<p>&nbsp;<\/p>\n<p style=\"text-align: justify\"><strong>if&#8230;elseif&#8230;.else Statement<\/strong>:The if&#8230;.elseif&#8230;else statement executes different codes for more than two\u00a0 Conditions.<\/p>\n<p>&nbsp;<\/p>\n<p><strong>Syntax<\/strong><\/p>\n<p>&nbsp;<\/p>\n<p>if (condition) {<\/p>\n<p>code to be executed if this condition is true; } elseif (condition) {<\/p>\n<p>code to be executed if this condition is true; }<\/p>\n<p>else {<\/p>\n<p>code to be executed if all conditions are false;}<\/p>\n<p>&nbsp;<\/p>\n<p><strong>Example for if..elseif\u2026else statement:<\/strong><\/p>\n<p>&nbsp;<\/p>\n<p>&lt;html&gt;<\/p>\n<p>&lt;body&gt;<\/p>\n<p>&lt;?php<\/p>\n<p>$d=date(&#8220;D&#8221;);<\/p>\n<p>if ($d==&#8221;Fri&#8221;)<\/p>\n<p>echo &#8220;Have a nice weekend!&#8221;;<\/p>\n<p>elseif ($d==&#8221;Sun&#8221;)<\/p>\n<p>echo &#8220;Have a nice Sunday!&#8221;;<\/p>\n<p>else<\/p>\n<p>echo &#8220;Have a nice day!&#8221;; ?&gt;<\/p>\n<p>&lt;\/body&gt;<\/p>\n<p>&lt;\/html&gt;<\/p>\n<p>&nbsp;<\/p>\n<p><strong>Output<\/strong>:<\/p>\n<p>&nbsp;<\/p>\n<p>The following example output is &#8220;Have a nice weekend!&#8221;<\/p>\n<p>if the current day is Friday, and &#8220;Have a nice Sunday!&#8221;<\/p>\n<p>if the current day is Sunday.<\/p>\n<p>Otherwise it will output &#8220;Have a nice day!&#8221;<\/p>\n<p>&nbsp;<\/p>\n<p><strong>Switch Statement:<\/strong><\/p>\n<\/div>\n<p style=\"text-align: justify\"><span style=\"text-align: initial;font-size: 1em\">\u00a0 Switch statement can be used in situations where we are forced to select one of many blocks of code to be executed.<\/span><\/p>\n<div>\n<p><strong>\u00a0 \u00a0Syntax for Switch statement in PHP:<\/strong><\/p>\n<p>&nbsp;<\/p>\n<p>switch (n) {<\/p>\n<p>case label1:<\/p>\n<p>code to be executed if n=label1;<\/p>\n<p>break;<\/p>\n<p>case label2:<\/p>\n<p>code to be executed if n=label2;<\/p>\n<p>break;&#8230;<\/p>\n<p>default:<\/p>\n<p>code to be executed if n is different from all labels;<\/p>\n<p>}<\/p>\n<p>&nbsp;<\/p>\n<p><strong>Example of switch Statement:<\/strong><\/p>\n<p>&nbsp;<\/p>\n<p>&lt;?php<\/p>\n<p>$num=20;<\/p>\n<p>switch($num){<\/p>\n<p>case 10:<\/p>\n<p>echo(&#8220;number is equals to 10&#8221;);<\/p>\n<p>break;<\/p>\n<p>case 20:<\/p>\n<p>echo(&#8220;number is equal to 20&#8221;);<\/p>\n<p>break;<\/p>\n<p>case 30:<\/p>\n<p>echo(&#8220;number is equal to 30&#8221;);<\/p>\n<p>break;<\/p>\n<p>default:<\/p>\n<p>echo(&#8220;number is not equal to 10, 20 or 30&#8221;);<\/p>\n<p>} ?&gt;<\/p>\n<p>Based on the case values, corresponding echo statements would get executed.<\/p>\n<p>&nbsp;<\/p>\n<p><strong>LOOP STATEMENTS:<\/strong><\/p>\n<p>&nbsp;<\/p>\n<p style=\"text-align: justify\">Loop statements in PHP are used to execute the same block of code until the given condition is satisfied. Very often when we write code, we want the same block of code to run a number of times. We can use looping statements in our code to perform this.In PHP we have the following types of looping statements:<\/p>\n<\/div>\n<p><strong style=\"text-align: initial;font-size: 1em\">\u00a0 \u00a0while <\/strong><span style=\"text-align: initial;font-size: 1em\">&#8211; loops through a block of code if and as long as a specified condition is\u00a0<\/span><span style=\"text-align: initial;font-size: 1em\">true.<\/span><\/p>\n<p>&nbsp;<\/p>\n<p style=\"text-align: justify\"><strong style=\"text-align: initial;font-size: 1em\">do&#8230;while <\/strong><span style=\"text-align: initial;font-size: 1em\">&#8211; loops through a block of code once, and then repeats the loop as long as a special condition is true.<\/span><\/p>\n<p>&nbsp;<\/p>\n<p style=\"text-align: justify\"><strong style=\"text-align: initial;font-size: 1em\">for &#8211; <\/strong><span style=\"text-align: initial;font-size: 1em\">loops through a block of code a specified number of times.<\/span><\/p>\n<p>&nbsp;<\/p>\n<p style=\"text-align: justify\"><strong style=\"text-align: initial;font-size: 1em\">foreach <\/strong><span style=\"text-align: initial;font-size: 1em\">&#8211; loops through a block of code for each element in an array.<\/span><\/p>\n<p>&nbsp;<\/p>\n<p style=\"text-align: justify\"><strong style=\"text-align: initial;font-size: 1em\">While Statement :<\/strong><span style=\"text-align: initial;font-size: 1em\">The while statement will execute a block of code if and as long as a condition is true.<\/span><\/p>\n<p>&nbsp;<\/p>\n<p style=\"text-align: justify\"><strong style=\"text-align: initial;font-size: 1em\">Syntax of While statement:<\/strong><\/p>\n<div>\n<p>\u00a0 \u00a0 \u00a0while (condition)<\/p>\n<p>code to be executed;<\/p>\n<p>&nbsp;<\/p>\n<p><strong>Example of While statement:<\/strong><\/p>\n<p>&nbsp;<\/p>\n<p>&lt;?php<\/p>\n<p>$i=1;<\/p>\n<p>while($i&lt;=5) {<\/p>\n<p>echo &#8220;The number is &#8221; . $i . &#8220;&lt;br \/&gt;&#8221;;<\/p>\n<p>$i++;<\/p>\n<p>} ?&gt;<\/p>\n<p>&nbsp;<\/p>\n<p><strong>Output:<\/strong><\/p>\n<p>&nbsp;<\/p>\n<p>The number is 1 The number is 2 The number is 3 The number is 4<\/p>\n<p>&nbsp;<\/p>\n<p style=\"text-align: justify\"><strong>do&#8230;while Loop Statement :<\/strong>The do&#8230;while loop will always execute the block of code once, it will then check the condition, and repeat the loop until the specified condition is true.<\/p>\n<p>&nbsp;<\/p>\n<p><strong>Syntax of do\u2026while statement:<\/strong><\/p>\n<p>&nbsp;<\/p>\n<p>do {<\/p>\n<p>code to be executed;<\/p>\n<p>} while (condition is true);<\/p>\n<p>&nbsp;<\/p>\n<p><strong>Example:<\/strong><\/p>\n<p>&nbsp;<\/p>\n<p>&lt;?php<\/p>\n<p>$n=1;<\/p>\n<p>do{<\/p>\n<p>echo &#8220;$n&lt;br\/&gt;&#8221;;<\/p>\n<p>$n++;<\/p>\n<p>}while($n&lt;=10); ?&gt;<\/p>\n<\/div>\n<p style=\"text-align: justify\"><strong style=\"text-align: initial;font-size: 1em\">\u00a0 \u00a0for Loop Statement :<\/strong><span style=\"text-align: initial;font-size: 1em\">PHP for loop statement can be used to traverse a set of code for the specified number of times.It can be used only if the number of iterations is known, otherwise while loop has to be used.<\/span><\/p>\n<div>\n<p><strong>\u00a0 \u00a0 Syntax \u2013 for Loop statement:<\/strong>for(initialization; condition; increment\/decrement){ \/\/code to be executed<\/p>\n<p>}<\/p>\n<p>&nbsp;<\/p>\n<p><strong>Example \u2013 for Loop statement:<\/strong><\/p>\n<p>&nbsp;<\/p>\n<p>&lt;?php<\/p>\n<p>for ($i = 1; $i &lt;= 10; $i++)<\/p>\n<p>{<\/p>\n<p>echo $i;<\/p>\n<p>}<\/p>\n<p>?&gt;<\/p>\n<p>&nbsp;<\/p>\n<p style=\"text-align: justify\"><strong>for each Loop Statement <\/strong>:The foreach loop works only on arrays, and is used to loop through each key\/value pair in an array.<\/p>\n<p>&nbsp;<\/p>\n<p><strong>Syntax:<\/strong><\/p>\n<p>&nbsp;<\/p>\n<p>foreach ($array as $value) {<\/p>\n<p>code to be executed;<\/p>\n<p>}<\/p>\n<p>&nbsp;<\/p>\n<p><strong>Example- for each Loop Statement:<\/strong><\/p>\n<p>&nbsp;<\/p>\n<p>&lt;?php<\/p>\n<p>$season=array(&#8220;summer&#8221;,&#8221;winter&#8221;,&#8221;spring&#8221;,&#8221;autumn&#8221;);<\/p>\n<p>foreach( $season as $arr )<\/p>\n<p>{<\/p>\n<p>echo &#8220;Season is: $arr&lt;br \/&gt;&#8221;;<\/p>\n<p>}<\/p>\n<p>?&gt;<\/p>\n<p>&nbsp;<\/p>\n<p style=\"text-align: justify\"><strong>Break Statements: <\/strong>PHP break statement breaks the execution of current for, while, do-while, switch and for-each loop. If we use a break statement inside inner loop, it breaks the execution of inner loop only.<\/p>\n<p>&nbsp;<\/p>\n<p><strong>Syntax:<\/strong><\/p>\n<p>&nbsp;<\/p>\n<p>jump statement;<\/p>\n<p>break;<\/p>\n<\/div>\n<div>\n<p><strong>\u00a0 Example for break statement:<\/strong><\/p>\n<p>&nbsp;<\/p>\n<p>&lt;?php<\/p>\n<p>for($i=1;$i&lt;=10;$i++){<\/p>\n<p>echo &#8220;$i&lt;br\/&gt;&#8221;;<\/p>\n<p>if($i==5){ break; }<\/p>\n<p>}<\/p>\n<p>?&gt;<\/p>\n<p>&nbsp;<\/p>\n<p style=\"text-align: justify\"><strong>Continue Statements: <\/strong>The continue statement is used within looping structures to skip the rest of the current loop iteration and continue the execution at the point of condition evaluation and then it begins the next iteration.<\/p>\n<p>&nbsp;<\/p>\n<p><strong>Example:<\/strong><\/p>\n<p>&nbsp;<\/p>\n<p>&lt;?php<\/p>\n<p>$array = array(1, 2, 3, 4, 5, 6, 7, 8, 9, 0);<\/p>\n<p>foreach( $array as $value )<\/p>\n<p>{<\/p>\n<p>if( $value == 3 )<\/p>\n<p>continue;<\/p>\n<p>echo &#8220;Value is $value &lt;br \/&gt;&#8221;;<\/p>\n<p>}<\/p>\n<p>?&gt;<\/p>\n<p>&nbsp;<\/p>\n<p><strong>4.\u00a0\u00a0 PHP FUNCTIONS<\/strong><\/p>\n<p>&nbsp;<\/p>\n<p style=\"text-align: justify\">PHP function is a piece of code that can be reused many times. This can take input as an argument list and return values. There are thousands of built-in functions in PHP.In PHP, we can define Conditional function, Function within Function and Recursive function also.<\/p>\n<p>&nbsp;<\/p>\n<p><strong>4.1 User Defined Functions<\/strong><\/p>\n<p>&nbsp;<\/p>\n<p style=\"text-align: justify\">Besides the built-in PHP functions, we can create our own functions which are known as user defined functions. A function is a block of statements that can be used repeatedly in a program.A function will not execute immediately when a page loads but it will be executed when a function is invoked.A user defined function declaration starts with the word &#8220;function&#8221;.<\/p>\n<p>&nbsp;<\/p>\n<p><strong>Syntax:<\/strong><\/p>\n<p>&nbsp;<\/p>\n<p>function functionName()<\/p>\n<p>{<\/p>\n<p>code to be executed;<\/p>\n<p>}<\/p>\n<p>&nbsp;<\/p>\n<p><strong>Example:<\/strong><\/p>\n<\/div>\n<p><span style=\"text-align: initial;font-size: 1em\">\u00a0 \u00a0&lt;?php<\/span><\/p>\n<p><span style=\"text-align: initial;font-size: 1em\">functionsayHello()<\/span><\/p>\n<p><span style=\"text-align: initial;font-size: 1em\">{<\/span><\/p>\n<p><span style=\"text-align: initial;font-size: 1em\">E<\/span><span style=\"text-align: initial;font-size: 1em\">cho &#8220;Hello PHP Function&#8221;;<\/span><\/p>\n<p><span style=\"text-align: initial;font-size: 1em\">}<\/span><\/p>\n<p><span style=\"text-align: initial;font-size: 1em\">sayHello();\/\/calling function<\/span><\/p>\n<p><span style=\"text-align: initial;font-size: 1em\">?&gt;<\/span><\/p>\n<div>\n<p><strong>\u00a0 \u00a0Output:<\/strong>Hello PHP Function<\/p>\n<p>&nbsp;<\/p>\n<p><strong>Rules for defining a function:<\/strong><\/p>\n<p style=\"text-align: justify\">A valid function name starts with a letter or underscore, followed by any number of letters, numbers, or underscores.<\/p>\n<p>&nbsp;<\/p>\n<p>It can&#8217;t be started with numbers or special symbols.<\/p>\n<p>&nbsp;<\/p>\n<p style=\"text-align: justify\"><strong>PHP Function Arguments: <\/strong>Information may be passed to functions via the argument list, which is a comma-delimited list of expressions. The arguments are evaluated from left to right.PHP supports passing arguments to the functions using anyone of the types: pass by value (the default), passing by reference, and default argument values. Variable-length argument lists are also supported in PHP. The example given below passes a single argument to PHP function<\/p>\n<p>&nbsp;<\/p>\n<p>&lt;?php<\/p>\n<p>functionsayHello($name){<\/p>\n<p>echo &#8220;Hello $name&lt;br\/&gt;&#8221;; }<\/p>\n<p>sayHello(&#8220;Vimal&#8221;);\u00a0 sayHello(&#8220;John&#8221;);<\/p>\n<p>?&gt;<\/p>\n<p>&nbsp;<\/p>\n<p style=\"text-align: justify\"><strong>PHP Call ByReference: <\/strong>In this method, the value passed to the function does not modify the actual value by default (call by value). But the value can be modified by passing value as a reference.By default, value passed to the function is call by value. To pass value as a reference, it is advised to use ampersand (&amp;) symbol before the argument name.<\/p>\n<p>&nbsp;<\/p>\n<p><strong>Example:<\/strong><\/p>\n<p>&nbsp;<\/p>\n<p>&lt;?php<\/p>\n<p>function adder(&amp;$str2) {<\/p>\n<p>$str2 .= &#8216;Call By Reference&#8217;; }<\/p>\n<p>$str = &#8216;Hello &#8216;; adder($str);\u00a0 echo $str;<\/p>\n<p>?&gt;<\/p>\n<p>&nbsp;<\/p>\n<p><strong>Output:<\/strong>Call By Reference<\/p>\n<\/div>\n<p style=\"text-align: justify\"><strong style=\"text-align: initial;font-size: 1em\">\u00a0 \u00a0PHP Default Argument Value:<\/strong><span style=\"text-align: initial;font-size: 1em\">The following example shows how to use a default parameter. If we call the function setHeight() without arguments it takes the default value as argument.<\/span><\/p>\n<div>\n<p>&nbsp;<\/p>\n<p><strong>Example:<\/strong><\/p>\n<p>&nbsp;<\/p>\n<p>&lt;?php<\/p>\n<p>functionsetHeight($minheight = 50) {<\/p>\n<p>echo &#8220;The height is : $minheight&lt;br&gt;&#8221;;\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 }<\/p>\n<p>setHeight(350);<\/p>\n<p>setHeight(); \/\/ will use the default value of 50<\/p>\n<p>setHeight(135);<\/p>\n<p>?&gt;<\/p>\n<p>&nbsp;<\/p>\n<p style=\"text-align: justify\"><strong>PHP Functions &#8211; Returning values: <\/strong>Apart from the functions defined above, functions can also be defined and used to return values.<\/p>\n<p>&nbsp;<\/p>\n<p><strong>Example:<\/strong><\/p>\n<p>&nbsp;<\/p>\n<p>&lt;?php<\/p>\n<p>function add($x,$y)<\/p>\n<p>{<\/p>\n<p>$total = $x + $y;<\/p>\n<p>return $total;<\/p>\n<p>}<\/p>\n<p>echo &#8220;1 + 16 = &#8221; . add(1,16);<\/p>\n<p>?&gt;<\/p>\n<p>&nbsp;<\/p>\n<p><strong>Output: <\/strong>1 + 16 = 17<\/p>\n<p>&nbsp;<\/p>\n<p style=\"text-align: justify\"><strong>PHP Call By Value: <\/strong>PHP allows the user to call function by value and reference both.In case of PHP call by value, actual value does not get altered, if it is modified inside the function.<\/p>\n<p>&nbsp;<\/p>\n<p><strong>Example:<\/strong><\/p>\n<p>&nbsp;<\/p>\n<p>&lt;?php<\/p>\n<p>function adder($str2) {<\/p>\n<p>$str2 .= &#8216;Call By Value&#8217;;<\/p>\n<p>}<\/p>\n<p>$str = &#8216;Hello &#8216;;<\/p>\n<p>adder($str);<\/p>\n<p>echo $str;<\/p>\n<p>?&gt;<\/p>\n<p>&nbsp;<\/p>\n<p><strong>Output:<\/strong>Hello<\/p>\n<\/div>\n<p style=\"text-align: justify\"><strong style=\"text-align: initial;font-size: 1em\">\u00a0 PHP Variable Length Argument Function: <\/strong><span style=\"text-align: initial;font-size: 1em\">PHP supports the concept of variable length argument functions. This means that if a variable name has parentheses appended to it, PHP will look for a function with the same name as whatever the variable evaluates to, and will attempt to execute it. Among other things, this can be used to implement callbacks, function tables, and so forth.Variable functions won&#8217;t work with language constructs such as echo, print, unset(), isset(), empty(), include, require and the like. Wrapper functions can be utilized to make use of any of these constructs as variable functions.<\/span><\/p>\n<div>\n<p>&nbsp;<\/p>\n<p><strong>Variable length argument function example:<\/strong><\/p>\n<p>&nbsp;<\/p>\n<p>&lt;?php<\/p>\n<p>function foo() {<\/p>\n<p>echo &#8220;In foo()&lt;br \/&gt;\\n&#8221;;<\/p>\n<p>}<\/p>\n<p>function bar($arg = &#8221;) {<\/p>\n<p>echo &#8220;In bar(); argument was &#8216;$arg&#8217;.&lt;br \/&gt;\\n&#8221;; }<\/p>\n<p>\/\/\u00a0 This is a wrapper function around echo functionechoit($string) { echo $string; } $func = &#8216;foo&#8217;;<\/p>\n<p>$func();\u00a0 \/\/ This calls foo()<\/p>\n<p>$func = &#8216;bar&#8217;;<\/p>\n<p>$func(&#8216;test&#8217;); \/\/ This calls bar()<\/p>\n<p>$func = &#8216;echoit&#8217;;<\/p>\n<p>$func(&#8216;test&#8217;); \/\/ This calls echoit()<\/p>\n<p>?&gt;<\/p>\n<p>&nbsp;<\/p>\n<p><strong>Advantage of using PHP Functions:<\/strong><\/p>\n<p>&nbsp;<\/p>\n<p>Code Reusability Less Code<\/p>\n<p>Easy to understand.<\/p>\n<p>&nbsp;<\/p>\n<p><strong>5.\u00a0\u00a0<\/strong><strong>PHP ARRAYS<\/strong><\/p>\n<p>&nbsp;<\/p>\n<p style=\"text-align: justify\">An array stores multiple values in one single variable.Arrays have names that begin with $.PHP array is an ordered map (contains value on the basis of key) which is used to hold multiple values of similar type in a single variable. The element type is not specified and it can mix the data types too.Suppose we need to store roll numbers of 100 students then we can use array variable roll which can store 100 values in single variable with index.<\/p>\n<p>&nbsp;<\/p>\n<p><strong>Example:<\/strong><\/p>\n<\/div>\n<p style=\"text-align: justify\"><span style=\"text-align: initial;font-size: 1em\">Create an Array in PHPusing the array() language construct. It takes any number of comma-separated key =&gt; value pairs as arguments.<\/span><\/p>\n<div>\n<p><strong>\u00a0 \u00a0 Syntax:<\/strong>array();<\/p>\n<p>array(key =&gt; value, key2 =&gt; value2, key3 =&gt; value3, &#8230;);<\/p>\n<p><strong>Example:<\/strong>$shapes = array(&#8220;square&#8221;,&#8221;rectangle&#8221;,&#8221;circle&#8221;,&#8221;oval&#8221;);<\/p>\n<p>&nbsp;<\/p>\n<p><strong>PHP Array Types<\/strong><\/p>\n<p>&nbsp;<\/p>\n<p>There are 3 types of array in PHP.<\/p>\n<ul>\n<li style=\"text-align: justify\"><strong>Indexed Array <\/strong>&#8211; An array with a numeric index<\/li>\n<li style=\"text-align: justify\"><strong>Associative Array <\/strong>&#8211; An array with strings as index. This stores element values in association with key values rather than in a linear index order.<\/li>\n<li style=\"text-align: justify\"><strong>Multidimensional Array &#8211; <\/strong>An array containing one or more arrays<\/li>\n<\/ul>\n<p style=\"text-align: justify\"><strong>PHP Indexed Arrays:<\/strong>PHP index is represented by number which starts from 0. We can store number, string and objects in the PHP array. All PHP array elements are assigned to an index number by default. There are two ways to create indexed arrays where the index can be assigned automatically (index always starts at 0),like this:<\/p>\n<p>&nbsp;<\/p>\n<p><strong>Type 1<\/strong><strong>:<\/strong>$season=array(&#8220;summer&#8221;,&#8221;winter&#8221;,&#8221;spring&#8221;,&#8221;autumn&#8221;);<\/p>\n<p>&nbsp;<\/p>\n<p><strong>Type 2<\/strong><strong>:<\/strong>$season[0]=&#8221;summer&#8221;;<\/p>\n<p>$season[1]=&#8221;winter&#8221;;<\/p>\n<p>$season[2]=&#8221;spring&#8221;;<\/p>\n<p>$season[3]=&#8221;autumn&#8221;;<\/p>\n<p>&nbsp;<\/p>\n<p><strong>PHP Indexed Arrays Examples:<\/strong><\/p>\n<p>&nbsp;<\/p>\n<p><strong>Example 1:<\/strong><\/p>\n<p>&nbsp;<\/p>\n<p>&lt;?php<\/p>\n<p>$cars = array(&#8220;Volvo&#8221;, &#8220;BMW&#8221;, &#8220;Toyota&#8221;);<\/p>\n<p>echo &#8220;I like &#8221; . $cars[0] . &#8220;, &#8221; . $cars[1] . &#8221; and &#8221; . $cars[2] . &#8220;.&#8221;; ?&gt;<\/p>\n<p>&nbsp;<\/p>\n<p><strong>Example 2:<\/strong><\/p>\n<\/div>\n<p><span style=\"text-align: initial;font-size: 1em\">\u00a0 \u00a0 &lt;?php<\/span><\/p>\n<p><span style=\"text-align: initial;font-size: 1em\">$size[0]=&#8221;Big&#8221;;<\/span><\/p>\n<p><span style=\"text-align: initial;font-size: 1em\">$size[1]=&#8221;Medium&#8221;;<\/span><\/p>\n<p><span style=\"text-align: initial;font-size: 1em\">$size[2]=&#8221;Short&#8221;;<\/span><\/p>\n<p><span style=\"text-align: initial;font-size: 1em\">echo &#8220;Size: $size[0], $size[1] and $size[2]&#8221;; ?&gt;<\/span><\/p>\n<p>&nbsp;<\/p>\n<div>\n<p style=\"text-align: justify\"><strong>PHP Associative Array:<\/strong>The associative arrays are very similar to numeric arrays in term of functionality but they are different in terms of their index.Associative array will have their index as string so that we can establish a strong association between key and values.There are two ways to create an associative array:<\/p>\n<p>&nbsp;<\/p>\n<p>$age = array(&#8220;Peter&#8221;=&gt;&#8221;35&#8221;, &#8220;Ben&#8221;=&gt;&#8221;37&#8221;, &#8220;Joe&#8221;=&gt;&#8221;43&#8221;);<\/p>\n<p>(Or)<\/p>\n<p>$age[&#8216;Peter&#8217;] = &#8220;35&#8221;;<\/p>\n<p>$age[&#8216;Ben&#8217;] = &#8220;37&#8221;;<\/p>\n<p>$age[&#8216;Joe&#8217;] = &#8220;43&#8221;;<\/p>\n<p>&nbsp;<\/p>\n<p><strong>Example of PHP Associative Arrays<\/strong><\/p>\n<p>&nbsp;<\/p>\n<p>&lt;?php\u00a0\u00a0\u00a0\u00a0\u00a0 \/* First method to associate create array. *\/<\/p>\n<p>$salaries = array(&#8220;Kumar&#8221; =&gt; 2000, &#8220;Bala&#8221; =&gt; 1000, &#8220;Sudharsan&#8221; =&gt; 500);<\/p>\n<p>echo &#8220;Salary of Kumar is &#8220;. $salaries[&#8216;Kumar&#8217;] . &#8220;&lt;br \/&gt;&#8221;; echo &#8220;Salary of Bala is &#8220;. $salaries[&#8216;Bala&#8217;]. &#8220;&lt;br \/&gt;&#8221;;<\/p>\n<p>echo &#8220;Salary of Sudharsan is &#8220;. $salaries[&#8216;Sudharsan&#8217;]. &#8220;&lt;br \/&gt;&#8221;;<\/p>\n<p>\/* Second method to create array. *\/<\/p>\n<p>$salaries[&#8216;Kumar&#8217;] = &#8220;high&#8221;;<\/p>\n<p>$salaries[&#8216;Bala&#8217;] = &#8220;medium&#8221;;<\/p>\n<p>$salaries[&#8216;Sudharsan&#8217;] = &#8220;low&#8221;;<\/p>\n<p>echo &#8220;Salary of Kumar is &#8220;. $salaries[&#8216;Kumar&#8217;] . &#8220;&lt;br \/&gt;&#8221;;<\/p>\n<p><span style=\"text-align: initial;font-size: 1em\">echo &#8220;Salary of Bala is &#8220;. $salaries[&#8216;Bala&#8217;]. &#8220;&lt;br \/&gt;&#8221;;<\/span><\/p>\n<p><span style=\"text-align: initial;font-size: 1em\">echo &#8220;Salary of Sudharsan is &#8220;. $salaries[&#8216;Sudharsan&#8217;]. &#8220;&lt;br \/&gt;&#8221;; ?&gt;<\/span><\/p>\n<\/div>\n<div>\n<p><strong>\u00a0 \u00a0 Output<\/strong><\/p>\n<p>&nbsp;<\/p>\n<p>Salary of Kumar is 2000<\/p>\n<p>Salary of Bala is 1000<\/p>\n<p>Salary of Sudharsan is 500<\/p>\n<p>Salary of Kumar is high<\/p>\n<p>Salary of Bala is medium<\/p>\n<p>Salary of Sudharsan is low<\/p>\n<p>&nbsp;<\/p>\n<p style=\"text-align: justify\"><strong>PHP Multidimensional Arrays:<\/strong>PHP multidimensional array is otherwise known as array of arrays. It allows the user to store tabular data in an array. PHP multidimensional array can be represented in the form of matrix which is represented by row * column.<\/p>\n<p>&nbsp;<\/p>\n<p><strong>Multidimensional array Example:<\/strong><\/p>\n<p>&nbsp;<\/p>\n<p>$emp = array<\/p>\n<p>(<\/p>\n<p>array(1,\u201csachin&#8221;,400000),<\/p>\n<p>array(2,&#8221;john&#8221;,500000),<\/p>\n<p>array(3,&#8221;rahul&#8221;,300000)<\/p>\n<p>);<\/p>\n<p>A simple example of PHP multidimensional array is given below:<\/p>\n<p>Example of PHP Multidimensional Array:<\/p>\n<p>&lt;?php<\/p>\n<p>$marks = array(<\/p>\n<p>&#8220;Sachin&#8221; =&gt; array (<\/p>\n<p>&#8220;physics&#8221; =&gt; 35,<\/p>\n<p>&#8220;maths&#8221; =&gt; 30,<\/p>\n<p>&#8220;chemistry&#8221; =&gt; 39<\/p>\n<p>),<\/p>\n<p><span style=\"font-size: 1em;text-align: initial\">&#8220;Raju&#8221; =&gt; array (<\/span><\/p>\n<p><span style=\"text-align: initial;font-size: 1em\">&#8220;physics&#8221; =&gt; 30,<\/span><\/p>\n<p><span style=\"text-align: initial;font-size: 1em\">&#8220;maths&#8221; =&gt; 32,<\/span><\/p>\n<p><span style=\"text-align: initial;font-size: 1em\">&#8220;chemistry&#8221; =&gt; 29<\/span><\/p>\n<p><span style=\"text-align: initial;font-size: 1em\">),<\/span><\/p>\n<p><span style=\"text-align: initial;font-size: 1em\">&#8220;Venkat&#8221; =&gt; array (<\/span><\/p>\n<p><span style=\"text-align: initial;font-size: 1em\">&#8220;physics&#8221; =&gt; 31,<\/span><\/p>\n<p><span style=\"text-align: initial;font-size: 1em\">&#8220;maths&#8221; =&gt; 22,<\/span><\/p>\n<p><span style=\"text-align: initial;font-size: 1em\">&#8220;chemistry&#8221; =&gt; 39<\/span><\/p>\n<p><span style=\"text-align: initial;font-size: 1em\">)<\/span><\/p>\n<p><span style=\"text-align: initial;font-size: 1em\">);<\/span><\/p>\n<p><span style=\"text-align: initial;font-size: 1em\">\/* Accessing multi-dimensional array values *\/<\/span><\/p>\n<p><span style=\"text-align: initial;font-size: 1em\">echo &#8220;Marks for Sachin in physics : &#8221; ;<\/span><\/p>\n<p><span style=\"text-align: initial;font-size: 1em\">E<\/span><span style=\"text-align: initial;font-size: 1em\">cho $marks[&#8216;Sachin&#8217;][&#8216;physics&#8217;] . &#8220;&lt;br \/&gt;&#8221;;<\/span><\/p>\n<p><span style=\"text-align: initial;font-size: 1em\">echo &#8220;Marks for Raju in maths : &#8220;;<\/span><\/p>\n<p><span style=\"text-align: initial;font-size: 1em\">echo $marks[&#8216;Raju&#8217;][&#8216;maths&#8217;] . &#8220;&lt;br \/&gt;&#8221;;<\/span><\/p>\n<p><span style=\"text-align: initial;font-size: 1em\">echo &#8220;Marks for Venkat in chemistry : &#8221; ;<\/span><\/p>\n<p><span style=\"text-align: initial;font-size: 1em\">echo $marks[&#8216;Venkat&#8217;][&#8216;chemistry&#8217;] . &#8220;&lt;br \/&gt;&#8221;;<\/span><span style=\"text-align: initial;font-size: 1em\">?&gt;<\/span><\/p>\n<\/div>\n<div>\n<p><strong>\u00a0 \u00a0Output for Multidimensional Arrays:<\/strong><\/p>\n<p>&nbsp;<\/p>\n<p>Marks for Sachin in physics : 35<\/p>\n<p>Marks for Raju in maths : 32<\/p>\n<p>Marks for Venkat in chemistry : 39<\/p>\n<p>&nbsp;<\/p>\n<p><strong>Advantages of PHP Array<\/strong><\/p>\n<p>&nbsp;<\/p>\n<p><strong>Lesser amount of Code:<\/strong>There is no need to define multiple variables.<\/p>\n<p>&nbsp;<\/p>\n<p style=\"text-align: justify\"><strong>Easy to traverse: <\/strong>By the help of single loop, we can traverse all the elements of an array easily and quickly.<\/p>\n<p>&nbsp;<\/p>\n<p><strong>Sorting: <\/strong>We can sort the elements of array easily.<\/p>\n<\/div>\n<p style=\"text-align: justify\">\u00a0 Previous module has discussed the deployment of PHP programs in XAMPP\/ WAMPP server. PHP scripts can be easily written using the syntax, operators, statements, functions, strings and arrays discussed in this module and deployed in XAMPP\/ WAMPP server for the successful execution of web pages.<\/p>\n<p>&nbsp;<\/p>\n<p><strong>Summary<\/strong><\/p>\n<p>&nbsp;<\/p>\n<p style=\"text-align: justify\">This module is intended to discuss about the various operators available in PHP along with the strings applicable in this script. Also, the various types of conditional statements have been discussed with examples. Usage of PHP Arrays and Functions with various types applicable on it has been visited with suitable examples for successful creation and deployment of web pages in web server.<\/p>\n<p>&nbsp;<\/p>\n<p><strong>Web Links<\/strong><\/p>\n<ul>\n<li><a href=\"https:\/\/www.w3schools.com\/php\/\">https:\/\/www.w3schools.com\/php\/<\/a><\/li>\n<li><a href=\"http:\/\/www.c4learn.com\/php\/php-continue-statement\/\">http:\/\/www.c4learn.com\/php\/php-continue-statement\/<\/a><\/li>\n<li><a href=\"http:\/\/www.webstepbook.com\/supplements.shtml\">http:\/\/www.webstepbook.com\/supplements.shtml<\/a><\/li>\n<li><a href=\"http:\/\/sg2.php.net\/manual\/en\/\">http:\/\/sg2.php.net\/manual\/en\/<\/a><\/li>\n<li><a href=\"http:\/\/www.javatpoint.com\/php-tutorial\">http:\/\/www.javatpoint.com\/php-tutorial<\/a><\/li>\n<li><a href=\"http:\/\/www.w3schools.com\/php\/default.asp\">http:\/\/www.w3schools.com\/php\/default.asp<\/a><\/li>\n<li><a href=\"https:\/\/github.com\/linghangedu\/PHP-Primer\">https:\/\/github.com\/linghangedu\/PHP-Primer<\/a><\/li>\n<li><a href=\"https:\/\/www.javatpoint.com\/php-tutorial\">https:\/\/www.javatpoint.com\/php-tutorial<\/a><\/li>\n<li><a href=\"http:\/\/www.php.net\/\">http:\/\/www.php.net\/<\/a><\/li>\n<li>Steven Holzner, \u201c PHP: The Complete Reference\u201d, First Edition, McGraw-Hill Education,2007.<\/li>\n<li>Deitel and Deitel, \u201c Internet and World Wide Web: How to Program\u201d, Fifth Edition, Pearson Education, 2012.<\/li>\n<li>David Sklar and Adam Trachtenberg, \u201cPHP Cookbook\u201d, 3rd Edition, O\u2019Reilly Media, 2014<\/li>\n<\/ul>\n","protected":false},"author":4,"menu_order":34,"template":"","meta":{"pb_show_title":"on","pb_short_title":"","pb_subtitle":"","pb_authors":["dr-s-abirami"],"pb_section_license":""},"chapter-type":[],"contributor":[59],"license":[],"class_list":["post-341","chapter","type-chapter","status-publish","hentry","contributor-dr-s-abirami"],"part":3,"_links":{"self":[{"href":"https:\/\/ebooks.inflibnet.ac.in\/csp12\/wp-json\/pressbooks\/v2\/chapters\/341","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ebooks.inflibnet.ac.in\/csp12\/wp-json\/pressbooks\/v2\/chapters"}],"about":[{"href":"https:\/\/ebooks.inflibnet.ac.in\/csp12\/wp-json\/wp\/v2\/types\/chapter"}],"author":[{"embeddable":true,"href":"https:\/\/ebooks.inflibnet.ac.in\/csp12\/wp-json\/wp\/v2\/users\/4"}],"version-history":[{"count":1,"href":"https:\/\/ebooks.inflibnet.ac.in\/csp12\/wp-json\/pressbooks\/v2\/chapters\/341\/revisions"}],"predecessor-version":[{"id":350,"href":"https:\/\/ebooks.inflibnet.ac.in\/csp12\/wp-json\/pressbooks\/v2\/chapters\/341\/revisions\/350"}],"part":[{"href":"https:\/\/ebooks.inflibnet.ac.in\/csp12\/wp-json\/pressbooks\/v2\/parts\/3"}],"metadata":[{"href":"https:\/\/ebooks.inflibnet.ac.in\/csp12\/wp-json\/pressbooks\/v2\/chapters\/341\/metadata\/"}],"wp:attachment":[{"href":"https:\/\/ebooks.inflibnet.ac.in\/csp12\/wp-json\/wp\/v2\/media?parent=341"}],"wp:term":[{"taxonomy":"chapter-type","embeddable":true,"href":"https:\/\/ebooks.inflibnet.ac.in\/csp12\/wp-json\/pressbooks\/v2\/chapter-type?post=341"},{"taxonomy":"contributor","embeddable":true,"href":"https:\/\/ebooks.inflibnet.ac.in\/csp12\/wp-json\/wp\/v2\/contributor?post=341"},{"taxonomy":"license","embeddable":true,"href":"https:\/\/ebooks.inflibnet.ac.in\/csp12\/wp-json\/wp\/v2\/license?post=341"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}