12th Standard Syllabus & Materials
12th Standard
TN 12th English Poem - 6 - Incident of the French Camp Sample Question Papers Study Material - QB365 Set A
NEW12th Standard
TN 12th English Prose - 6 - On the Rule of the Road Sample Question Papers Study Material - QB365 Set A
NEW12th Standard
TN 12th English Prose - 5 - The Chair Sample Question Papers Study Material - QB365 Set A
NEW12th Standard
TN 12th English Supplementary - 4 - The Midnight Visitor Sample Question Papers Study Material - QB365 Set A
NEW12th Standard
TN 12th English Poem - 4 - Ulysses Sample Question Papers Study Material - QB365 Set A
NEW12th Standard
TN 12th English Prose - 4 - The Summit Sample Question Papers Study Material - QB365 Set A

Published on: 27/11/2019
PHP Function and Array
Download Tamil Nadu 12th Standard Computer Applications question papers, model tests, one-mark questions, important questions, and public exam papers in PDF format. Free study materials and answer keys for TN State Board students.
Questions + Answers key
Take MCQ Computer Applications Test

1.
__________ arrays are a key-value pair data structure.
Associative
Indexed
Multi-dimensional
All of these
2.
______ stores more than one value of same data type in single array variable.
Arrays
Function
Indexed array
Multidimensional array
3.
As compared to associative arrays vector arrays are much
Faster
Slower
Stable
None of them
4.
For finding non empty elements in array we use
is_array ( ) function
size of ( ) function
array_count ( ) function
array_count ( ) function
5.
A function in PHP starts with __
Function
__def
def
function
6.
What is indexed array?
7.
How index will be assigned in indexed array?
8.
Usage of Array in PHP.
9.
Define User defined Function.
10.
Write the advantages of functions.
11.
Write the rules for parameters.
12.
Differentiate Associate array and Multidimensional array.
13.
Differentiate user defined and system defined Functions.
14.
Write the purpose of parameterized Function.
15.
What is the syntax for defining a function in PHP?
16.
Explain Indexed array and Associate array in PHP.
17.
Explain Array concepts and their types.
18.
Explain the Multidimensional Array.
19.
Explain Function concepts in PHP.
1.
(b)
Indexed
2.
(a)
Arrays
3.
(b)
Slower
4.
(b)
size of ( ) function
5.
(a)
Function
6.
The index can be assigned automatically in a collection of data set
7.
The index can be assigned automatically in a collection of data set.
8.
1. The array() function is used to create an array.
2. In PHP,there are three types of arrays:
i). Indexed arrays - Arrays with numeric index
ii). Associative arrays - Arrays with named keys
iii). Multidimensional arrays - Arrays containing one or more arrays
9.
It gives privilege to user to write their own specific operation inside of existing program module is called as User Defined Function.
10.
1. Reducing duplication of code
2. Decomposing complex problems into simpler pieces
3. Improving clarity of the code
4. Reuse of code
5. Information hiding
11.
1. PHP Parameterized functions are the functions with parameters or arguments.
2. The parameter is also called as arguments, it is like variables.
Rules:
1. The arguments are mentioned after the function name and inside of the parenthesis.
2. There is no limit for sending arguments, just separate them with a comma notation.
12.
| Associate array | Multidimensional array |
|---|---|
| Associative arrays are arrays that use named keys that you assign to them. | An array containing one or more arrays. |
| It storing data in a liner | Multi-dimensional arrays that are two, three, four, five, or more levels deep. |
| We can associate the name with each array element in PHP using = > symbol. | It can be represented in the form of a matrix which is represented by row * column. |
13.
| User defined Functions | System define Functions |
|---|---|
| (i) Functions are provided by the user. (ie) we can create own functions. | (i) Built-in function are functions that exist in PHP installation package. |
| (ii) Example function insertMsg() { echo "Helo world" } insertMsg(); |
(ii) Example rename_function() |
14.
To pass any number of parameters inside a function.
They are specified inside the parenthesis, after the function name.
Syntax:
function School Name($sname, $Strength)
{
echo $sname." in Tamilnadu and Student Strength is".$Strength;
}
15.
Syntax
function functionName([parameter list])
{
// code to be executed
}
16.
Indexed array:
An indexed array is an array that uses a numeric index to access its elements. The index is a number that starts at 0 for the first element and increases by 1 for each subsequent element.
We can create an indexed array in PHP,
(i) by enclosing a comma-separated list of values in square brackets (or)
(ii) by using the array() function.
Syntax
$array Variable=[element1, element2, element 3, ... elementN];
(or)
$arrayVariable array( element1, element2, element3.... elementN);
Examples
(a) $fruits = ['apple, "banana, 'orange'];
(b) $fruits = array('apple, "banana, 'orange');
Associative array
An associative array is a data structure that store a collection of key-value pairs. The keys are used to identify the values, and the values can be of any data type. The keys in an associative array are often called "labels" because they label or identify the corresponding values.
We can create an associative array in PHP,
(i) by enclosing a comma-separated list of key-value pairs in square brackets (or)
(ii) by using the array() function.
Syntax
| $arrayVariable [ "key1" => "value1", "key2"=>"value2", "key3"=>"value3" "key N=> "valueN" ]; |
Example
$student [
"Name" => "Ram",
"Age" => 25,
"Place" => "Trichy"
];
17.
Array is a concept that stores more than one value of same data type in single array variable.
They are 3 types of array concepts in PHP.
(i) Indexed Arrays
(ii) Associative Array and
(iii) Multi-Dimensional Array
(i) Indexed Arrays
Array defines with the keyword array()
Syntax:
Array with numeric index for the available values in array variable which contains key value pair as user can take the value using keys.
Example:
$teacher_name=array("Iniyan", "Kavin", "Nilani");
echo "The students name are".$teacher_name[0].$teacher_name[1]..
(ii) Associative Arrays
Associative arrays are a key-value pair data structure.
Syntax:
array (key=> value, key =>, value, key => Value, etc.);
key=Specifies the key (numeric or string)
Valme - Specifies the value
Example
<$ php
$Marks
array"Student1"=>"35","Student2"=>"17"Student3"=>"43");
echo "Studenti mark is. $Marks("Student1]." is eligible for qualification";
echo "Student2 mark is. $Marks Student2"]." is not eligible for qualification";
?>
(iii) Multidimensional Arrays:
Array containing one or more arrays is called multidimensional array. PHP accepts array with two, three four or more levels.
Example:
< ?php
// A two-dimensional array
$student=array
(
array("Iniyan", 100, 96),
array("Kavin", 60, 59),
array("Nilani", 1313, 139)
);
echo $$student [0][0].": Tamil Mark: ".$student [0][1].". English mark: ".$student [0] [2]."< br > ";
echo $$student [1][0].": Tamil Mark: ".$student [1][1].". English mark: ".$student [1] [2]."< br > ";
echo $$student [2}[0].": Tamil Mark:".$student [2][1].".English mark: ".$student [2] [2]."< br >
? >
18.
Multidimensional Arrays:
Array containing one or more arrays is called multidimensional array. PHP accepts array with two, three four or more levels.
Example:
// A two-dimensional array
$student=array
(
array("Iniyan", 100, 96),
array("Kavin", 60, 59),
array("Nilani", 1313, 139)
);
echo $$student [0][0].": Tamil Mark: ".$student [0][1].". English mark: ".$student [0] [2]."< br >";
echo $$student [1][0].": Tamil Mark: ".$student [1][1].". English mark: ".$student [1] [2]."< br >";
echo $$student [2}[0].": Tamil Mark:".$student [2][1].".English mark: ".$student [2] [2]."< br >
? >
19.
Function in PHP:
A block of segment in a program that performs a specific operation such as Insert, Execute, Delete, Calculate etc.
A function is a type of sub-routine or procedure in a program.
The function can be divided into three types as follows.
(i) User defined Function
(ii) Pre-defined or System defined or Built-in Function
(iii) Parameterized Function
(i) User defined Function
PHP gives a privilege to user to write own specific operation inside of existing program module.
Two important steps the programmer has to create for users defined functions are
(a) Function Declaration
(b) Function Calling
(a) Function Declaration
A user defined function declaration begins with the keyword "Function".
User can write any custom logic inside in function block.
Syntax:
function functionName()
{
custom logic code to be executed;
}
(b) Function Calling
A function declaration part will be executed by a call to the function.
Programmer has to create function calling part inside the respective program.
Syntax:
functionName();
(ii) Pre-defined or System defined or built-in Function
Built-in functions are functions that exist in PHP installation package.
Functions can either return values when called or can simply perform an operation without returning any value.
Example:
rename_function()
This function renames original name to new name.
Parameter is also called as arguments just like variables.
Arguments are mentioned after the function name and inside the parenthesis.
There is no limit for sending arguments, just separate them with a comma notation.
Examples :
Parameterized function with one argument, two arguments respectively.
(i) function School Name ($sname)
(ii) function School Name ($sname, $strength)
12th Standard Syllabus & Materials
12th Standard
TN 12th English Supplementary - 3 - The Hour of Truth (Play) Sample Question Papers Study Material - QB365 Set A
NEW12th Standard
TN 12th English Poem - 3 - All the World’s a Stage Sample Question Papers Study Material - QB365 Set A
NEW12th Standard
TN 12th English Prose - 3 - In Celebration of Being Alive Sample Question Papers Study Material - QB365 Set A
NEW12th Standard
TN 12th English Supplementary - 2 - Life of Pi Sample Question Papers Study Material - QB365 Set A
Tamilnadu Stateboard 12th Standard Subjects

Maths

Chemistry

Physics

Biology

Computer Science

Business Maths and Statistics

Economics

Commerce

Accountancy

History

Computer Applications

Biology

Computer Technology

Computer Applications

Computer Science

Business Maths and Statistics

Commerce

Economics

Maths

Chemistry

Physics

Computer Technology

History

Accountancy

Tamil

English

French
Tamilnadu Stateboard Standards