0% found this document useful (0 votes)
25 views6 pages

WT 2mq

The document outlines key features of PHP and HTML, including PHP's ability to generate dynamic content and interact with databases, while HTML structures web pages. It also discusses various PHP scripts and their outputs, including the use of functions like usort(), explode(), and array_diff(). Additionally, it covers topics such as string handling, CSS integration, and the purpose of certain PHP functions like var_dump() and mail().

Uploaded by

soham12306
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
25 views6 pages

WT 2mq

The document outlines key features of PHP and HTML, including PHP's ability to generate dynamic content and interact with databases, while HTML structures web pages. It also discusses various PHP scripts and their outputs, including the use of functions like usort(), explode(), and array_diff(). Additionally, it covers topics such as string handling, CSS integration, and the purpose of certain PHP functions like var_dump() and mail().

Uploaded by

soham12306
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

‭a) Write any 2 features of PHP & HTML.

‭●‬ ‭PHP:‬
‭1.‬ P ‭ HP is a server-side scripting language that allows for dynamic content‬
‭generation.‬
‭2.‬ ‭PHP can easily interact with databases like MySQL and PostgreSQL.‬
‭●‬ ‭HTML:‬
‭1.‬ ‭HTML is a markup language used to structure web pages with elements‬
‭like headings, paragraphs, links, etc.‬
‭2.‬ ‭It supports embedding multimedia elements such as images, audio,‬
‭and video.‬

‭b) Write the output of the following PHP Script:‬

‭ hp‬
p
‭Copy code‬
‭<?php‬
‭$age = array("Anna"=>"45", "Julie"=>"38", "Benne"=>"53");‬
‭usort($age);‬
‭print_r($age);‬
‭?>‬

‭●‬ T
‭ he script will throw a‬‭warning/error‬‭because‬‭usort()‬‭is designed for indexed‬
‭arrays, not associative arrays.‬

‭c) Write the output of the following script:‬

‭ hp‬
p
‭Copy code‬
‭<?php‬
‭$a='PHP';‬
‭$b='$a interpolation ';‬
‭echo $b;‬
‭?>‬

‭●‬ T
‭ he output will be:‬‭'$a interpolation'‬‭. Single quotes prevent variable‬
‭interpolation in PHP.‬
‭d) Write the output of the following PHP Script:‬

‭ hp‬
p
‭Copy code‬
‭$str='abc,pqr,lmn,xyz';‬
‭$p = explode(',', $str, 3);‬
‭print_r($p);‬

‭●‬ ‭The output will be:‬

‭ hp‬
p
‭Copy code‬
‭Array‬
‭(‬
‭[0] => abc‬
‭[1] => pqr‬
‭[2] => lmn,xyz‬
‭)‬

‭ he‬‭explode()‬‭function splits the string into 3 parts, and the last part includes the rest‬
T
‭of the string after the third split.‬

‭e) What is the output of the following?‬

‭ hp‬
p
‭Copy code‬
‭<?php‬
‭$p = array(1,2,3,4,5);‬
‭$q = array(1,3,5,7,9);‬
‭$s = array_diff($p, $q);‬
‭print_r($s);‬
‭?>‬

‭●‬ ‭The output will be:‬

‭ hp‬
p
‭Copy code‬
‭Array‬
‭(‬
‭[1] => 2‬
‭[3] => 4‬
‭)‬

‭ he‬‭array_diff()‬‭function returns the values from array $p that are not present in‬
T
‭array $q.‬

‭a) Differentiate between single quoted string and double quoted string.‬

‭●‬ S ‭ ingle quoted strings‬‭do not process variables or special characters (except‬
‭backslashes and single quotes themselves).‬
‭●‬ ‭Double quoted strings‬‭allow variable interpolation and handle escape‬
‭sequences like‬‭\n‬‭(new line) and‬‭\t‬‭(tab).‬

‭b) How is External CSS used?‬

‭●‬ E
‭ xternal CSS is linked to an HTML document using the‬‭<link>‬‭tag placed‬
‭within the‬‭<head>‬‭section. The‬‭href‬‭attribute specifies the path to the CSS file,‬
‭and the‬‭rel‬‭attribute defines the relation as‬‭stylesheet‬‭.‬

‭c) Write any two functions of decomposing a string with a suitable example.‬

‭1.‬ ‭explode()‬‭: Splits a string into an array based on a delimiter.‬


‭○‬ ‭Example:‬‭explode(',', 'apple,banana,grape')‬‭will result in‬‭['apple',‬
‭'banana', 'grape']‬‭.‬
‭2.‬ ‭str_split()‬‭: Splits a string into an array, either character-by-character or by a‬
‭given length.‬
‭○‬ ‭Example:‬‭str_split('hello', 2)‬‭results in‬‭['he', 'll', 'o']‬‭.‬

‭d) How to find the position of the first occurrence of a substring in a string?‬

‭●‬ U
‭ se the‬‭strpos()‬‭function to find the position of the first occurrence of a‬
‭substring. For example,‬‭strpos('hello world', 'world')‬‭will return‬‭6‭.‬‬

‭e) What is the purpose of array_splice() function?‬

‭●‬ T
‭ he‬‭array_splice()‬‭function removes a portion of an array and can replace it‬
‭with new elements. It's also used to remove elements without replacement.‬
‭Explain List in HTML.‬

‭●‬ L
‭ ists in HTML are used to present items in a structured format. There are two‬
‭main types of lists:‬
‭1.‬ ‭Ordered List (<ol>)‬‭: Displays items in a numbered sequence.‬
‭2.‬ ‭Unordered List (<ul>)‬‭: Displays items with bullet points.‬

‭What is Casting of operators?‬

‭●‬ C
‭ asting operators in PHP are used to convert a variable from one data type to‬
‭another. For example,‬‭(int)‬‭converts a value to an integer, and‬‭(string)‬‭converts‬
‭it to a string.‬

‭Find the Output:‬

‭ hp‬
p
‭Copy code‬
‭$subjects = array('physics', 'chem', 'math', 'bio', 'cs', 'drama');‬
‭$rl = array_splice($subjects, 2, 3);‬
‭print_r($subjects);‬

‭●‬ ‭The output will be:‬

‭ hp‬
p
‭Copy code‬
‭Array‬
‭(‬
‭[0] => physics‬
‭[1] => chem‬
‭[2] => drama‬
‭)‬

‭array_splice()‬‭removed‬‭math‬‭,‬‭bio‬‭, and‬‭cs‬‭, leaving‬‭physics‬‭,‬‭chem‬‭, and‬‭drama‬‭.‬

‭Explain the following functions:‬


‭●‬ v ‭ ar_dump()‬‭: Displays structured information about one or more variables,‬
‭including its type and value.‬
‭●‬ ‭trim()‬‭: Removes whitespace or other predefined characters from the‬
‭beginning and end of a string.‬

‭Define the types of web pages.‬

‭1.‬ S ‭ tatic Web Pages‬‭: Pages that remain the same for every user. They do not‬
‭change based on user interaction.‬
‭2.‬ ‭Dynamic Web Pages‬‭: Pages that change content dynamically based on user‬
‭interaction or server-side data.‬

‭a) Find the Output:‬

‭ hp‬
p
‭Copy code‬
‭$city = 'pune';‬
‭$string = 'I like $city very much!';‬
‭echo $string;‬

‭●‬ T
‭ he output will be:‬‭I like $city very much!‬‭because single quotes prevent‬
‭variable interpolation.‬

‭b) Find the Output:‬

‭ hp‬
p
‭Copy code‬
‭$file = fopen("sample.txt", "w");‬
‭echo fwrite($file, "Hello! How are you Rahul?");‬
‭fclose($file);‬

‭●‬ ‭The output will be‬‭27‬‭, which is the number of bytes written to the file.‬

‭c) Find output of the following code:‬

‭ hp‬
p
‭Copy code‬
‭ a = "1E3 points of light" + 1;‬
$
‭var_dump($a);‬

‭●‬ T
‭ he output will be:‬‭float(1001)‬‭. The string‬‭"1E3"‬‭is interpreted as‬‭1000‬‭in‬
‭scientific notation, and adding‬‭1‬‭results in‬‭1001‬‭.‬

‭d) What is the use of var_dump() function?‬

‭●‬ T
‭ he‬‭var_dump()‬‭function outputs the detailed information of a variable, such‬
‭as its data type and value, including arrays and objects.‬

‭e) What is the use of mail() function? Give syntax of it.‬

‭●‬ T
‭ he‬‭mail()‬‭function is used to send emails in PHP. Syntax:‬‭mail(to, subject,‬
‭message, headers)‬‭.‬

You might also like