CS310 Sample Paper
CS310 Sample Paper
FINALTERM EXAMINATION
Fall 2022
CS310 - Open Source Web Application Development (PHP, PERL, CGI, MySql)
Time: 90 min
Marks: 60
<?php
$num = "123";
if (!filter_var($num, FILTER_VALIDATE_INT))
echo("Integer is not valid");
else
echo("Integer is valid");
?>
A. No output is produced
B. The string "Integer is not valid" is displayed
C. The string "Integer is valid" is displayed
D. An error occurs
fclose($handle);
?>
Answer:
<?php
$file = 'mydata.txt';
$data = "Welcome to File Handling.";
$handle = fopen($file, 'a'); //fopen() is used to open the file
$write = fwrite($handle, $data); //fwrite() is used to write in the file
fclose($handle);
?>
Answer:
WordPress is a free and open-source content management system (CMS) designed to
make it easy for users to create, manage, and publish websites, blogs, and other types of
content. With WordPress, you can perform tasks such as writing blog posts, adding
pages, creating menus, and managing media files without needing technical knowledge or
programming skills.
Question No: 47 (Marks: 05)
Write down the PHP code to determine the existence of a text file and write “ABC” in it.
Then check data was written successfully or not then close the file.
Answer:
<?php
?>
if (mysqli_query($conn, $sql)) {
echo "New record created successfully";
} else {
echo "Error: " . $sql . "<br>" . mysqli_error($conn);
}
mysqli_close($conn);