Get the most accurate TN Board Solutions for Class 12 Computer Applications Chapter 05 PHP Function and Array here. Updated for the 2026-27 academic session, these solutions are based on the latest TN Board textbooks for Class 12 Computer Applications. Our expert-created answers for Class 12 Computer Applications are available for free download in PDF format.
Detailed Chapter 05 PHP Function and Array TN Board Solutions for Class 12 Computer Applications
For Class 12 students, solving TN Board textbook questions is the most effective way to build a strong conceptual foundation. Our Class 12 Computer Applications solutions follow a detailed, step-by-step approach to ensure you understand the logic behind every answer. Practicing these Chapter 05 PHP Function and Array solutions will improve your exam performance.
Class 12 Computer Applications Chapter 05 PHP Function and Array TN Board Solutions PDF
Part I
Choose The Correct Answers
Question 1. Which one of the following is the right way of defining a function in PHP?
(a) function { function body }
(b) data type functionName(parameters) { function body }
(c) functionName(parameters) { function body }
(d) function functionName(parameters) { function body }
Answer: (d) function functionName(parameters) { function body }
In simple words: In PHP, you define a function by using the `function` keyword, followed by the function's name, then parentheses for parameters, and finally curly braces for the code that runs inside the function. This structure tells PHP exactly how the function works.
π― Exam Tip: Remember that PHP is a loosely typed language, so you don't specify a `data type` for function parameters or return values in the function definition itself.
Question 2. A function in PHP which starts with (double underscore) is known as ______________.
(a) Magic Function
(b) Inbuilt Function
(c) Default Function
(d) User Defined Function
Answer: (a) Magic Function
In simple words: In PHP, special functions that start with two underscores (like `__construct`) are called magic functions. They perform specific actions automatically under certain conditions, such as when an object is created or a method is called that doesn't exist.
π― Exam Tip: Magic functions are built-in PHP features that allow you to add "magic" to classes, handling events like object creation, destruction, property access, and method calls in unique ways. Do not create your own functions starting with `__` unless you are overriding an existing magic method.
Question 3. PHP's numerically indexed array begins with position ______________.
(a) 1
(b) 2
(c) 0
(d) -1
Answer: (c) 0
In simple words: Like many programming languages, PHP arrays that are indexed by numbers always start counting from zero. This means the very first item in the array is at position 0, the second at 1, and so on.
π― Exam Tip: Understanding that array indices start at 0 is fundamental in programming. Misremembering this can lead to "off-by-one" errors where you access the wrong element or go out of bounds.
Question 4. Which of the following are correct ways of creating an array?
i) state[0] = "Tamilnaduβ;
ii) $state[] = array("Tamilnadu");
iii) $state[0] = "Tamilnadu";
iv) $state = array("Tamilnaduβ);
(a) iii) and iv)
(b) ii) and iii)
(c) Only i)
(d) ii), iii) and iv)
Answer: (d) ii), iii) and iv)
In simple words: In PHP, you can create an array by assigning a value to a specific index (like `$state[0] = "Tamilnadu"`), adding an element to the end of an array (`$state[] = ...`), or by directly using the `array()` function to set up the array with values. All these methods help define how an array stores information.
π― Exam Tip: While all listed options (except `i)` which misses a dollar sign on `$state`) are syntactically valid ways to create or modify arrays, using the `array()` constructor or square brackets `[]` for new arrays are the most common and clear methods. Option `i)` is invalid because it uses `state[0]` instead of `$state[0]` for a variable.
Question 5. What will be the output of the following PHP code?<?php
$a=array("A","Cat","Dog ","A","Dog ");
$b=array("Cat", "A", "Tiger");
$c=array_combine($a,$b);
print_r(array_count_values($c));
?>
(a) Array ([A] => 5 [Cat] = > 2 [Dog] => 2 [Tiger] = > 1)
(b) Array ([A] => 2 [Cat] => 2 [Dog] => 1 [Tiger] = > 1)
(c) Array ( [A] => 6 [Cat] => 1 [Dog] -> 2 [Tiger] = > 1)
(d) Array ([A] => 2 [Cat] => 1 [Dog] => 4 [Tiger] = > 1)
(e) None of these
Answer: (e) None of these
In simple words: The provided code will not run correctly because the `$a` array has 5 items and the `$b` array has only 3 items. The `array_combine()` function needs both arrays to have the same number of items to work properly. So, it will show an error, and the final output will not match any of the given options. The `array_count_values` function cannot work on an invalid `$c`.
π― Exam Tip: Always check the number of elements in arrays when using `array_combine()`. If the number of elements differs, PHP will generate a warning and `array_combine()` will return `false`, which often leads to further errors if not handled correctly.
Question 6. For finding nonempty elements in array we use ______________.
(a) is,array () function
(b) sizeof () function
(c) array_count () function
(d) count () function
Answer: (d) count () function
In simple words: To find out how many elements are in an array, including non-empty ones, you use the `count()` function. It simply gives you the total number of items stored in that array. The `sizeof()` function does the same thing, but `count()` is more commonly used.
π― Exam Tip: Both `count()` and `sizeof()` functions do the same job in PHP, returning the number of elements in an array. Using `count()` is generally preferred as it's more descriptive of its purpose. Note that `count()` will return `0` for an empty array.
Question 7. Indices of arrays can be either strings or numbers and they are denoted as ______________.
(a) $my_array {4}
(b) $my_array [4]
(c) $my_array | 4 |
(d) None of them
Answer: (b) $my_array [4]
In simple words: When you want to access an item in a PHP array, you use square brackets `[]` around the index. This index can be a number (for indexed arrays) or a text label (for associative arrays). The square brackets are the correct way to point to a specific item.
π― Exam Tip: Correctly using square brackets `[]` for array access is essential. Curly braces `{}` are used for accessing characters in a string, and pipes `|` have different meanings in programming (like bitwise OR), so they are not for array indexing.
Question 8. PHP arrays are also called as ______________.
(a) Vector arrays
(b) Perl arrays
(c) Hashes
(d) All of them
Answer: (a) Vector arrays
In simple words: PHP arrays are sometimes called vector arrays, especially when they only use numbers as their keys, starting from zero. This is one way to refer to them, similar to how other languages might call them lists or ordered arrays.
π― Exam Tip: While "vector array" specifically refers to numerically indexed arrays, it's worth noting that PHP arrays are very flexible and can act as indexed arrays, associative arrays (like "hashes" in other languages), and even multidimensional arrays.
Question 9. As compared to associative arrays vector arrays are much ______________.
(a) Faster
(b) Slower
(c) Stable
(d) None of them
Answer: (b) Slower
In simple words: Numerically indexed (vector) arrays can be slower than associative arrays for certain operations, especially when you need to quickly look up items using a specific key. This is because associative arrays are designed for efficient key-based access.
π― Exam Tip: The performance difference between indexed and associative arrays in PHP is often subtle and depends on the specific use case and PHP version. However, associative arrays are optimized for key-value lookups, making them conceptually "faster" for that specific task compared to iterating through an indexed array.
Question 10. What functions count elements in an array?
(a) count
(b) Sizeof
(c) Array_Count
(d) Count_array
Answer: (a) count
In simple words: The `count()` function is the primary way to find out how many elements are present in an array in PHP. It provides the total number of items, helping you understand the array's size.
π― Exam Tip: Remember that `sizeof()` also works as an alias for `count()`. While `array_count()` or `count_array()` might seem logical, they are not standard PHP functions for this purpose.
Short Answers
Question 1. Define Function in PHP.
Answer: In most programming languages, a function is a special block of code inside a program that does a specific job. For example, it might insert data, run calculations, or delete information. This special section is also called a function, and it acts like a smaller, reusable part of the main program. When needed, this block can be called to perform its task, making code more organized. One helpful feature of functions is that they make it easy to reuse the same code without writing it multiple times.
In simple words: A function in PHP is a piece of code that does a specific job. You can call it whenever you need that job done, which helps keep your program tidy and makes the code reusable.
π― Exam Tip: Emphasize that functions are "reusable blocks of code" that perform "specific operations" to score well. Mentioning their role in making code organized and efficient is also a good point.
Question 2. Define User define Function.
Answer: A User-Defined Function (UDF) in PHP gives programmers the power to create their own specific operations within an existing program. These functions let users write custom code for tasks that are unique to their application. The process of declaring a user-defined function always starts with the `function` keyword. This allows developers to encapsulate any custom logic needed into a manageable block of code.
- User-Defined Function (UDF) in PHP gives a privilege to the user to write their own specific operation inside of existing program module.
- A user-defined function declaration begins with the keyword βfunctionβ.
- Users can write any custom logic inside the function block.
In simple words: A user-defined function is a special block of code that you, the programmer, create to do a specific task. You start it with the word "function", and you can put any custom instructions inside it.
π― Exam Tip: Highlight that UDFs allow "custom logic" and that their declaration "begins with the `function` keyword". This shows understanding of their core purpose and syntax.
Question 3. What is parameterized Function?
Answer: A Parameterized Function in PHP is a function that uses special inputs called parameters or arguments. These parameters act like temporary variables that receive information when the function is called. This allows different pieces of data to be shared between the part of the program that calls the function and the function itself. You can pass as many arguments as you need, simply separating them with commas. Using parameters makes functions very flexible, as they can work with different data each time they are used. The arguments are always listed after the function name, inside parentheses.
- PHP Parameterized functions are the functions with parameters or arguments.
- Required information can be shared between function declaration and function calling part inside the program.
- The parameter is also called as arguments, it is like variables.
- The arguments are mentioned after the function name and inside of the parenthesis.
- There is no limit for sending arguments, just separate them with a comma notation.
In simple words: A parameterized function takes special inputs called parameters (or arguments). These inputs are like temporary variables that let you send different information to the function each time you use it. You list them inside the parentheses when you define the function.
π― Exam Tip: Focus on the idea that parameters allow "information sharing" between the calling code and the function. Mentioning they act "like variables" and are passed "inside parentheses" are key descriptive points.
Question 4. List out System defined Functions.
Answer: System-defined functions in PHP are ready-made functions that come built into the language. They provide useful tools for many common programming tasks. Some examples include functions to check the type of a variable. These functions save developers time by providing essential functionalities without needing to be written from scratch.
- `is_bool()` function: By using this function, we can check whether the variable is a boolean variable or not.
- `is_int()` function: By using this function, we can check the input variable is an integer or not.
- `is_float()` function: By using this function, we can check the float variable is an integer or not.
- `is_null()` function: By using the `is_null` function, we can check whether the variable is `NULL` or not.
In simple words: System-defined functions are functions that are already built into PHP. Examples are `is_bool()` to check if something is true/false, `is_int()` for whole numbers, `is_float()` for decimal numbers, and `is_null()` to see if something has no value.
π― Exam Tip: When listing system-defined functions, choose a few clear examples that illustrate different functionalities, such as type-checking functions (`is_int`, `is_string`, `is_array`). Briefly explaining what each does reinforces your answer.
Question 5. Write Syntax of the Function in PHP.
Answer: The basic structure for defining a function in PHP uses the `function` keyword, followed by the function's chosen name, then parentheses `()`, and finally a pair of curly braces `{}`. Any code you want the function to execute goes inside these curly braces. This clear syntax ensures that PHP understands where a function begins and ends. Using meaningful function names helps in understanding the code's purpose easily.SYNTAX:
function functionName()
{
Custom Logic code to be executed;
}
In simple words: To write a function, you start with the word `function`, then give it a name, add `()`, and then `{} `to hold all the code the function will run.
π― Exam Tip: The key elements of function syntax are `function` keyword, `functionName`, `parentheses`, and `curly braces`. Clearly showing these in a code block demonstrates full understanding.
Question 6. Define Array in PHP.
Answer: An array in PHP is a special type of variable that can hold more than one value at a time. All these values are usually of the same data type, making the array "homogeneous". Instead of storing each item in a separate variable, an array groups them together under one name. PHP supports three main kinds of arrays, each designed for different ways of storing and accessing data. Arrays are crucial for managing collections of related data efficiently.
They are 3 types of array in PHP.
1. Indexed Arrays
2. Associative Array and
3. Multi-Dimensional Array
In simple words: An array is like a container that stores many values, usually of the same type, all under one name. There are three main types: Indexed, Associative, and Multi-Dimensional.
π― Exam Tip: When defining arrays, mention that they "store more than one value" and typically represent "homogeneous" data. Listing the three main types of PHP arrays is also a good practice.
Question 7. Usage of Array in PHP.
Answer: In PHP, arrays are very useful for grouping related pieces of information. The `array()` function is the most common way to create an array, allowing you to quickly set up a collection of values. Arrays help organize data, making it easier to manage lists of items, key-value pairs, or even tables of information. They are fundamental for handling structured data in web applications.
In PHP, there are three types of arrays:
- Indexed arrays β Arrays with a numeric index
- Associative arrays β Arrays with named keys
- Multidimensional arrays β Arrays containing one or more arrays
In simple words: Arrays in PHP help you organize many related values under one variable name. You use the `array()` function to create them. There are three types: indexed (numbers for keys), associative (names for keys), and multidimensional (arrays inside other arrays).
π― Exam Tip: Focus on `array()` function for creation and explain that arrays are for "grouping related information." Briefly describing each type of array (indexed, associative, multidimensional) adds completeness.
Question 8. List out the types of the array in PHP.
Answer: PHP offers three main types of arrays, each designed for different ways of organizing and accessing data. Understanding these types is crucial for efficient data management in your programs. These different structures allow for flexibility in storing various kinds of data.
They are 3 types of array concepts in PHP.
1. Indexed Arrays,
2. Associative Array and
3. Multi-Dimensional Array.
In simple words: PHP has three kinds of arrays: Indexed Arrays (using numbers to find items), Associative Arrays (using names or labels to find items), and Multi-Dimensional Arrays (arrays that hold other arrays).
π― Exam Tip: Simply listing the three types: Indexed, Associative, and Multi-Dimensional Arrays is usually sufficient for this question. A brief description of each, as in the previous answer, can also be beneficial.
Question 9. Define associative array.
Answer: Associative arrays are a type of data structure where each item is stored as a key-value pair. Unlike simple indexed arrays that use numbers for positions, associative arrays let you assign unique, descriptive names (keys) to each piece of data. This means instead of finding data by its numerical position (like 0, 1, 2), you find it using its assigned key (like "name", "age", "city"). This makes it much easier to remember and reference specific pieces of information, especially when dealing with related properties of an object or record. For example, you might use "name" to get the name of a person.
In simple words: An associative array stores information using pairs of "keys" and "values". Instead of using numbers like 0 or 1, you use a name (like "name" or "age") to find a specific piece of data.
π― Exam Tip: The core concept of an associative array is the "key-value pair." Emphasize that the key is "unique" and "named" (often a string) rather than a numeric index.
Question 10. Write array Syntax in PHP.
Answer: The primary way to define an array in PHP is using the `array()` constructor, which allows you to specify keys and values. The syntax shows how you list pairs of `key => value`, separated by commas. Each `key` can be either a number or a string, and it acts as an identifier for its corresponding `value`. This flexible syntax allows for the creation of both indexed and associative arrays, making it versatile for many data organization needs.
`array(key=>value,key=>value,key=> value,etc.); key = Specifies the key (numeric or string value β Specifies the value)`
In simple words: To create an array, you use `array()` and inside it, you list `key => value` pairs. The `key` can be a number or a word, and the `value` is the data you want to store.
π― Exam Tip: Clearly show the `key => value` syntax inside the `array()` function. Explain that `key` can be numeric or string, and `value` is the data stored. This covers the most common array creation method.
Part III
Explain in brief answer
Question 1. Write the features System define Functions.
Answer: System-defined functions in PHP are pre-built blocks of code that are already part of the PHP language. These functions are designed to perform specific tasks, such as handling strings, managing arrays, or connecting to databases. They are highly reusable, meaning you can call them multiple times throughout your program without rewriting the code. These functions can either give back a value after they finish their task or simply complete an operation without returning anything. PHP includes a large collection of over 700 such built-in functions, making development faster and more efficient.
Features of System defined functions:
1. System defined functions are otherwise called as predefined or built-in functions.
2. PHP has over 700 built in functions that performs different tasks.
3. Built in functions are functions that exists in PHP installation package.
In simple words: System-defined functions are ready-made parts of PHP that do specific jobs. They are called "predefined" or "built-in" and come with PHP. There are more than 700 of them, helping you do many things in your code.
π― Exam Tip: Highlight that system-defined functions are "predefined" or "built-in" and perform "specific actions." Mentioning their reusability and the large number of functions available in PHP are good details.
Question 2. Write the purpose of parameterized Function.
Answer: Parameterized functions serve the important purpose of allowing information to be passed into a function when it is called. This means that a single function can operate on different data each time it's used, making it very versatile. An argument, which is what we call the actual data passed to a function, works just like a variable inside the function. These arguments are listed after the function's name within parentheses. You can send as many arguments as needed, simply separating each one with a comma. This feature makes functions flexible and powerful for various tasks, as they don't have to work with fixed data.
- Information can be passed to functions through arguments.
- An argument is just like a variable.
- Arguments are specified after the function name, inside the parentheses. We can add as many arguments as you want, just separate them with a comma.
In simple words: Parameterized functions let you send information into a function when you use it. This makes the function flexible, able to work with different data each time. You put these pieces of information, called arguments, inside the parentheses and separate them with commas.
π― Exam Tip: Emphasize that parameterized functions "pass information" using "arguments" (which are like variables) to make functions "reusable with different data."
Question 3. Differentiate user define and system define Functions.
Answer: User-defined and system-defined functions both perform specific tasks, but they differ in who creates them and how they are managed. User-defined functions give programmers the flexibility to tailor operations to their unique needs, while system-defined functions provide a robust set of ready-made tools. This distinction is important for understanding how to structure and optimize code.
| User-defined Functions | System-defined Functions |
|---|---|
| These are functions created by the user according to their specific requirements. | These are predefined functions that come built-in with PHP. |
| The name of a user-defined function can be changed by the user at any time. | The name of a system-defined function cannot be changed. |
| The function ID or name is decided by the user. | The function ID or name is given by the PHP developers. |
In simple words: User-defined functions are made by you for your specific needs, and you can change their names. System-defined functions are already built into PHP by its creators, and their names cannot be changed.
π― Exam Tip: For differentiation questions, a clear table format with direct comparisons for each point (e.g., who creates, who names, reusability) is ideal to score full marks.
Question 4. Write Short notes on Array.
Answer: An array in PHP is a powerful data structure that allows you to store multiple values within a single variable. These values are often of the same data type, making the array a collection of homogeneous elements. Arrays provide an organized way to manage lists or groups of related information, which is far more efficient than using separate variables for each item. PHP supports three primary types of arrays, each suited for different scenarios, providing flexibility for various programming needs. This versatility makes arrays indispensable in PHP development.
Array is a concept that stores more than one value of same data type (homogeneous) in single array variable. They are 3 types of array concepts in PHP.
1. Indexed Arrays,
2. Associative Array and
3. Multi-Dimensional Array.
In simple words: An array is a single variable in PHP that can hold many values, usually of the same kind. It helps organize data. There are three types: Indexed, Associative, and Multi-Dimensional arrays.
π― Exam Tip: When writing short notes on arrays, define what an array is ("stores multiple values in a single variable"), mention its nature ("homogeneous" data), and list the three main types.
Question 5. Differentiate Associate array and Multidimensional array.
Answer: Associative arrays and multidimensional arrays are two different ways PHP organizes data, each serving unique purposes. Associative arrays use named keys for direct access to values, making them ideal for representing records or objects. Multidimensional arrays, on the other hand, are designed to store complex, layered data, similar to tables or grids. Understanding their differences helps in choosing the right structure for your data.
| Associate array | Multidimensional array |
|---|---|
| Associative arrays use named keys that you assign to them. | An array containing one or more arrays. |
| It stores data in a linear fashion, with keys acting as unique identifiers. | Multidimensional arrays can be two, three, four, five, or more levels deep. |
| You can associate names with each array element using the `=>` symbol. | It can be represented like a matrix, with rows and columns. |
In simple words: Associative arrays use names to label each piece of data, while multidimensional arrays are arrays that contain other arrays, like a list within a list, creating layers of data.
π― Exam Tip: For differentiation, clearly state that associative arrays use "named keys" and multidimensional arrays are "arrays within arrays." Using a table format for comparison is highly recommended.
Part IV
Explain in detail
Question 1. Explain Function concepts in PHP.
Answer: In PHP, a function is a fundamental concept that refers to a self-contained block of code designed to perform a specific task. Just like in most programming languages, these blocks allow you to organize and reuse code effectively. Functions can perform various operations such as inserting data, executing commands, deleting records, or performing calculations. A function is essentially a type of subroutine or procedure within a larger program. This means it can be called upon whenever its specific task is needed, avoiding the repetition of code. Once a function is called, it executes its defined steps and can optionally return a data type value or `NULL` back to the part of the program that invoked it. Functions significantly improve code readability and maintainability. Generally, PHP functions are categorized into three main types:
1. User-defined Function,
2. Pre-defined or System or built-in Function, and
3. Parameterized Function.
1. User-Defined Function:
A User-Defined Function (UDF) in PHP gives the programmer the ability to write their own specific operations within an existing program. Creating these functions involves two crucial steps: first, declaring the function, and second, calling the function to execute its code. This flexibility allows developers to create custom logic tailored to their unique application requirements.
2. System-Defined Functions:
A system-defined function is a reusable piece of code that is already created and provided by the PHP system itself. These functions perform specific actions and are readily available for use. They can either return a value after their execution or simply perform an operation without any return value. PHP includes a vast library of over 700 such built-in functions, covering a wide range of tasks.
3. Parameterized Function:
PHP parameterized functions are functions that accept inputs, known as parameters or arguments. These parameters are like temporary variables that allow data to be passed into the function from the calling part of the program. This makes functions highly adaptable, as they can operate on different data each time they are called, enhancing their reusability and flexibility.
In simple words: Functions in PHP are blocks of code that do specific jobs, helping you reuse code and keep your program neat. There are three main kinds: User-defined functions (which you create), System-defined functions (which PHP already provides), and Parameterized functions (which take inputs to work with different data).
π― Exam Tip: When explaining function concepts, start with a general definition (reusable code block for a specific task), then elaborate on the three main types: User-defined, System-defined, and Parameterized functions, highlighting their key characteristics.
Question 2. Discuss in detail User-defined Functions.
Answer: User-defined functions (UDFs) in PHP are powerful tools that provide programmers with the flexibility to create their own custom operations within an existing program module. This capability is essential for writing modular, organized, and efficient code. The core idea is to encapsulate specific logic into a named block that can be called whenever needed, preventing code duplication. A key benefit is that UDFs can be tailored precisely to the unique requirements of an application. There are two critical steps a programmer must follow when creating and using user-defined functions: Function Declaration and Function Calling. After definition, these functions act as building blocks for more complex programs.
- User-Defined Function (UDF) in PHP gives a privilege to the user to write own specific operation inside of existing program module.
- Two important steps the Programmer has to create for users define Functions are:
Function Declaration
- A user-defined Function declaration begins with the keyword βfunctionβ.
- User can write any custom logic inside the function block.
Syntax:
`function functionName()`
`{`
`Custom Logic code to be executed;`
`}`
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();`
Example:
`<?php`
`function insertMsg() {`
`echo "Student Details Inserted Successfully!";`
`}`
`insertMsg(); // call the function`
`?>`
In simple words: User-defined functions are blocks of code you create to do specific jobs in your program. To use them, you first declare (or define) the function using the `function` keyword and then call it by its name to make it run. This helps you write your own rules for your program.
π― Exam Tip: When discussing UDFs in detail, define them first, then break down the process into "Function Declaration" (including syntax with `function` keyword and curly braces) and "Function Calling" (showing how to invoke it). An example code snippet greatly strengthens the explanation.
Question 3. Explain the Multidimensional Array.
Answer: A multidimensional array in PHP is an array that contains one or more other arrays within itself. Think of it like a table or a grid where each "cell" can itself be another array. PHP is capable of understanding and working with multidimensional arrays that can be two, three, four, five, or even more levels deep, allowing for complex data structures. This type of array is particularly useful for storing data that has a hierarchical or tabular relationship, such as a spreadsheet, a game board, or student records with multiple scores. However, managing arrays that are more than three levels deep can become quite challenging for most people due to their complexity. They are excellent for representing data with interconnected relationships.
1. A multidimensional array is an array containing one or more arrays.
2. PHP understands multidimensional arrays that are two, three, four, five, or more levels deep.
3. However, arrays more than three levels deep are hard to manage for most people.
Example:
`<?php`
`// A two-dimensional array for student data`
`$student_array = array(`
`array("Iniyan", 100, 96),`
`array("Kavin", 60, 59),`
`array("Nilani", 1313, 139)`
`);`
`echo $student_array[0][0].": Tamil Mark: ".$student_array[0][1]." English mark: ".$student_array[0][2]."`<br>`";`
`echo $student_array[1][0].": Tamil Mark: ".$student_array[1][1]." English mark: ".$student_array[1][2]."`<br>`";`
`echo $student_array[2][0].": Tamil Mark: ".$student_array[2][1]." English mark: ".$student_array[2][2]."`<br>`";`
`?>`
In simple words: A multidimensional array is an array that holds other arrays inside it, like a box containing smaller boxes. PHP can handle these arrays with many layers, which is good for organizing complex information, similar to a table or a list of lists.
π― Exam Tip: When explaining multidimensional arrays, define them as "arrays containing other arrays" and mention their use for "hierarchical or tabular data." Including a simple example with code demonstrating access to elements is very effective.
Question 4. Explain Array concepts and their types.
Answer: In PHP, an array is a special variable that allows you to store more than one value in a single variable. This makes it a very efficient way to manage collections of related data, rather than using many separate variables. The values within an array are often considered homogeneous, meaning they are of the same data type, which helps in organizing structured information. Arrays are fundamental to programming as they provide a flexible structure for storing lists, tables, or key-value pairs.
There are 3 types of array concepts in PHP, each serving different purposes:
1. Indexed Arrays:
These arrays use numeric indices (numbers) to identify and access elements. By default, the first element is at index `0`, the second at `1`, and so on. They are ideal for storing simple lists where the order of elements is important. The values can be retrieved using their numerical position.
2. Associative Arrays:
Unlike indexed arrays, associative arrays use named keys (strings) instead of numbers to identify elements. Each element is a key-value pair, allowing for more descriptive access to data. This type is excellent for storing records or properties of an object, where keys like "name", "age", or "city" make the data self-explanatory.
3. Multidimensional Arrays:
These are arrays that contain one or more other arrays. They are used to store complex data structures, similar to a table with rows and columns, or a list of lists. Multidimensional arrays are valuable for representing hierarchical data, such as a spreadsheet or a collection of student records, where each record might itself be an array of details. PHP supports arrays that can be several levels deep.
In simple words: An array in PHP is a single variable that holds many values, usually of the same kind. There are three types: Indexed Arrays (use numbers like 0, 1, 2 to find items), Associative Arrays (use names like "name", "age" to find items), and Multidimensional Arrays (arrays that store other arrays inside them, like a table).
π― Exam Tip: For this detailed explanation, first define what an array is, then clearly describe each of the three typesβIndexed, Associative, and Multidimensional Arraysβwith an emphasis on how elements are accessed and when each type is typically used.
Question 5. Explain Indexed array and Associatearray in PHP.
Answer:
Indexed Arrays: These arrays use numbers as their index to store and access values. Developers or users retrieve values from these arrays using these numeric keys.
Associative Arrays: These arrays are a type of data structure where each value is paired with a unique key. Instead of storing data in a simple list, associative arrays let you use meaningful names (keys) to store and reference your data within a collection. This makes it easier to remember and access specific data items.
In simple words: Indexed arrays use numbers to find items, like a list where items are at position 0, 1, 2. Associative arrays use names to find items, like a dictionary where you look up a word to find its meaning.
π― Exam Tip: Clearly state that indexed arrays use numeric keys and associative arrays use named (string) keys, as this is their fundamental difference.
12th Computer Applications Guide Introduction to Hypertext Pre-Processor Additional Important Questions and Answers
Choose The Correct Answers:
Part A
Question 1. A block of the segment in a program that performs specific operation tasks is known as
(a) Arrays
(b) Segments
(c) Functions
(d) All of these
Answer: (c) Functions
In simple words: A function is like a mini-program inside a bigger program that does a special job.
π― Exam Tip: Remember that functions are designed to perform specific, reusable tasks, making code organized and efficient.
Question 2. PHP has over _____ built-in functions.
(a) 200
(b) 500
(c) 700
(d) 900
Answer: (c) 700
In simple words: PHP comes with more than 700 ready-made tools (functions) that you can use in your code.
π― Exam Tip: Knowing the approximate number of built-in functions helps understand the richness of PHP's library.
Question 3. _____ is a concept that stores more than one value of the same data type in a single array variable.
(a) Arrays
(b) Segments
(c) Functions
(d) All of these
Answer: (a) Arrays
In simple words: An array is like a box that can hold many similar items, all under one name.
π― Exam Tip: The key idea of an array is to store multiple related values as a single entity, making it easy to manage collections of data.
Question 4. _______ arrays are a key-value pair data structure.
(a) Associative
(b) Indexed
(c) Multi-dimensional
(d) All of these
Answer: (a) Associative
In simple words: Associative arrays use names, not numbers, to store and find information.
π― Exam Tip: Focus on "key-value pair" as the defining characteristic of associative arrays, contrasting them with numeric-indexed arrays.
Question 5. Find the wrong statement from the following?
(a) pre-defined functions are called built-in functions
(b) pre-defined functions are called system functions
(c) parameterized functions are called system functions
Answer: (c) parameterized functions are called system functions
In simple words: The statement that "parameterized functions are called system functions" is not correct. Parameterized functions can be either built-in or user-defined, and they are named for having parameters, not for being system functions.
π― Exam Tip: Understand that "system defined" and "pre-defined" refer to functions provided by the language, while "parameterized" describes how a function accepts input, regardless of its origin.
Fill In The Blanks:
Question 1. PHP has over _____ functions built-in that perform different tasks.
Answer: 700
In simple words: PHP has more than 700 functions already made and ready to use.
π― Exam Tip: Remember this number as a general fact about the PHP language's capabilities.
Question 2. PHP functions are dived into ........ types.
Answer: three
In simple words: PHP functions are sorted into three main kinds.
π― Exam Tip: Be ready to name the three types: user-defined, pre-defined/system, and parameterized functions.
Question 3. A user-defined Function declaration begins with the keyword ........
Answer: function
In simple words: You start writing a new function in PHP by using the word "function".
π― Exam Tip: The `function` keyword is essential for defining any function in PHP, whether user-defined or built-in conceptually.
Question 4. The parameter is also called.............
Answer: arguments
In simple words: The inputs you give to a function are also known as arguments.
π― Exam Tip: The terms "parameters" and "arguments" are often used interchangeably in programming to refer to the values passed to a function.
Question 5. Array defines with the keyword ........
Answer: array()
In simple words: You create an array in PHP using the `array()` keyword.
π― Exam Tip: The `array()` construct is the primary way to declare and initialize arrays in PHP.
Syntax
1. Function Declaration:
function functionName()
{
Custom Logic code to be executed;
}
2. Function Calling:
functionName();
3. Indexed Arrays:
$Array_Variable = array( "value1β, βvalue2β, βvalue2");
4. Associative Arrays
array(key=>value,key=>value,key=>- value,etc.);
Choose The Incorrect Statements:
Question 1.
(a) PHP Functions are Reducing duplication of code
(b) PHP Functions are Decomposing complex problems into simpler pieces
(c) PHP Functions are Improving the clarity of the code
(d) PHP Functions are collections of variables.
Answer: (d) PHP Functions are collections of variables.
In simple words: Functions are blocks of code that do a job, not just a bunch of variables.
π― Exam Tip: Functions are about actions and processes, while variables are about storing data. Don't confuse their roles.
Question 2.
(a) PHP Functions are Reuse of code
(b) PHP Functions are Information hiding
(c) PHP Parameterized functions are the functions without parameters
(d) PHP arrays are using For each looping concepts
Answer: (c) PHP Parameterized functions are the functions without parameters
In simple words: The statement is wrong because parameterized functions are specifically designed to work with parameters.
π― Exam Tip: The name "parameterized" directly implies the presence and use of parameters within the function.
Question 3.
(a) Array is a collection of heterogeneous data
(b) An Array is a block of code that performs a specific action.
(c) A function is already created by the system it is a reusable piece
(d) An array is a special variable, which can hold more than one value at a time.
Answer: (b) An Array is a block of code that performs a specific action.
In simple words: This statement describes a function, not an array. Arrays are for storing data.
π― Exam Tip: Differentiate between the definition of an array (a data structure) and a function (a code block that performs an action).
Question 4.
(a) An array is a block of statements that can be used repeatedly in a program.
(b) The index can be assigned automatically in a collection of the data set
(c) A multidimensional array is an array containing one or more arrays.
(d) Associative arrays are arrays that use named keys you assign to them.
Answer: (a) An array is a block of statements that can be used repeatedly in a program.
In simple words: This statement describes a function, not an array. Arrays hold data.
π― Exam Tip: Pay close attention to how "array" and "function" are defined; mistaking one for the other is a common error.
Question 5.
(a) User Defined Function (UDF) in PHP gives a privilege to the user to write own specific operation inside of existing program module.
(b) A user-defined Function declaration begins with the keyword "function".
(c) A Function is a type of subroutine or procedure in a program.
(d) A Function will not be executed by a call to the Function
Answer: (d) A Function will not be executed by a call to the Function
In simple words: Functions only run when you tell them to by calling them.
π― Exam Tip: Emphasize that calling a function is crucial for its execution; without a call, the function's code will not run.
Match The Following:
Question. Match the following:
1. Indexed Arrays β System function
2. Associative Arrays β Function with arguments
3. Multidimensional Arrays β Key value pair
4. Parameterized function β Array containing one or more array
5. Predefined function β Numeric Index
Answer:
1. Numeric Index
2. Key valued pair
3. Array containing one or more array
4. Function with arguments
5. System Function
In simple words: This matches each type of array or function to its main characteristic or description. For example, indexed arrays use numbers to find items, while associative arrays use specific names.
π― Exam Tip: Review the definitions for each term (Indexed Arrays, Associative Arrays, Multidimensional Arrays, Parameterized functions, and Predefined functions) to correctly link them to their descriptions.
Very Short Answers
Question 1. Classify functions?
Answer: Functions can be categorized into three main types:
1. User-defined Function: Functions created by the programmer.
2. Pre-defined or System or Built-in Function: Functions that come with the programming language.
3. Parameterized Function: Functions that accept inputs (parameters) to perform their tasks.
In simple words: Functions are mainly of three kinds: ones you make, ones that come with the program, and ones that take inputs.
π― Exam Tip: Make sure to list all three classifications of functions and briefly explain what each means.
Question 2. What is an associative array?
Answer: Associative arrays are a type of array that use named keys, instead of numeric indexes, to identify and access their values. You assign these custom names (keys) when you create the array.
In simple words: An associative array lets you use names, not just numbers, to find and store data.
π― Exam Tip: The key differentiator for an associative array is the use of "named keys" (strings) rather than automatic numeric indexes.
Question 3. How index will be assigned in an indexed array?
Answer: In an indexed array, the index (position number) for each element is automatically assigned. It starts from 0 for the first element, 1 for the second, and so on, building a collection of data in a sequential order.
In simple words: In an indexed array, the computer automatically gives numbers to each item, starting from zero.
π― Exam Tip: Remember that indexed arrays in most programming languages are zero-based, meaning the first element is at index 0.
Question 4. What is a Multi-Dimensional Array?
Answer: A multidimensional array is an array that contains one or more other arrays as its elements. This means you can create arrays within arrays, allowing for complex data structures like grids or tables.
In simple words: A multidimensional array is like a big box that holds smaller boxes, and those smaller boxes can hold items.
π― Exam Tip: Visualize a multidimensional array as a table or a grid where each cell itself can be another array.
Part B
Short Answers
Question 1. Write a PHP program for function with one arguments?
Answer:
<?php
function School_Name($sname) {
echo $sname." in Tamilnadu.<br>";
}
School_Name ("Government Higher Secondary School Madurai");
School_Name ("Government Higher Secondary School Trichy");
School_Name ("Government Higher Secondary School Chennai");
School_Name ("Government Higher Secondary School Kanchipuram");
School_Name ("Government Higher Secondary School Tirunelveli");
?>This PHP program defines a function called `School_Name` which takes one argument, `$sname`. When called, it prints the school's name followed by "in Tamilnadu." The program then calls this function five times, each with a different school name, demonstrating how to reuse the function with varying inputs.In simple words: This code shows how to make a function that takes one input, like a school's name. It then uses this function many times to print different school names.
π― Exam Tip: When writing code examples, ensure the function definition is clear, the argument is used correctly within the function, and the function is called multiple times with different values to demonstrate its reusability.
Question 2. Give important characteristics of PHP functions?
Answer: Important characteristics of PHP functions include:
1. **Code Reusability:** Functions help reduce duplicated code by allowing a block of code to be used many times.
2. **Problem Decomposition:** They break down big problems into smaller, easier-to-manage pieces.
3. **Improved Clarity:** Functions make code easier to understand and read by organizing it into logical parts.
4. **Information Hiding:** They can hide the inner workings of a task, letting you use a function without knowing all its complex details.
5. **Modularity:** Functions promote modularity, meaning different parts of a program can be developed and tested independently.
In simple words: PHP functions help write code once and use it many times, break big tasks into small ones, make code clearer, hide complex details, and allow different parts of a program to work separately.
π― Exam Tip: Focus on benefits like reusability, modularity, and code organization, as these are the primary reasons for using functions in programming.
Free study material for Computer Applications
TN Board Solutions Class 12 Computer Applications Chapter 05 PHP Function and Array
Students can now access the TN Board Solutions for Chapter 05 PHP Function and Array prepared by teachers on our website. These solutions cover all questions in exercise in your Class 12 Computer Applications textbook. Each answer is updated based on the current academic session as per the latest TN Board syllabus.
Detailed Explanations for Chapter 05 PHP Function and Array
Our expert teachers have provided step-by-step explanations for all the difficult questions in the Class 12 Computer Applications chapter. Along with the final answers, we have also explained the concept behind it to help you build stronger understanding of each topic. This will be really helpful for Class 12 students who want to understand both theoretical and practical questions. By studying these TN Board Questions and Answers your basic concepts will improve a lot.
Benefits of using Computer Applications Class 12 Solved Papers
Using our Computer Applications solutions regularly students will be able to improve their logical thinking and problem-solving speed. These Class 12 solutions are a guide for self-study and homework assistance. Along with the chapter-wise solutions, you should also refer to our Revision Notes and Sample Papers for Chapter 05 PHP Function and Array to get a complete preparation experience.
FAQs
The complete and updated Samacheer Kalvi Class 12 Computer Applications Solutions Chapter 5 PHP Function and Array is available for free on StudiesToday.com. These solutions for Class 12 Computer Applications are as per latest TN Board curriculum.
Yes, our experts have revised the Samacheer Kalvi Class 12 Computer Applications Solutions Chapter 5 PHP Function and Array as per 2026 exam pattern. All textbook exercises have been solved and have added explanation about how the Computer Applications concepts are applied in case-study and assertion-reasoning questions.
Toppers recommend using TN Board language because TN Board marking schemes are strictly based on textbook definitions. Our Samacheer Kalvi Class 12 Computer Applications Solutions Chapter 5 PHP Function and Array will help students to get full marks in the theory paper.
Yes, we provide bilingual support for Class 12 Computer Applications. You can access Samacheer Kalvi Class 12 Computer Applications Solutions Chapter 5 PHP Function and Array in both English and Hindi medium.
Yes, you can download the entire Samacheer Kalvi Class 12 Computer Applications Solutions Chapter 5 PHP Function and Array in printable PDF format for offline study on any device.