0% found this document useful (0 votes)
20 views7 pages

CSC 381

The document outlines key concepts in PHP, JavaScript, and HTML, including object comparison operators, DOM access, and data types. It also covers file handling techniques in JavaScript, form submission methods in PHP, and exception handling keywords. Additionally, it provides examples of variable scope, function definitions, and basic data types in PHP.

Uploaded by

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

CSC 381

The document outlines key concepts in PHP, JavaScript, and HTML, including object comparison operators, DOM access, and data types. It also covers file handling techniques in JavaScript, form submission methods in PHP, and exception handling keywords. Additionally, it provides examples of variable scope, function definitions, and basic data types in PHP.

Uploaded by

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

the two operators used for comparison of objects in PHP are ?

The two operators used for the comparison of objects in PHP are:

== (Equality): Compares if two objects are instances of the same class and have the same properties
with equal values.

=== (Identity): Compares if two objects are instances of the same class, have the same properties with
equal values, and are the same instance (refer to the same object in memory).

when a webpage loads, the web browser produces a ------------ of the webpage and Javascript can access
all the elements of the webpage using ---------------

When a webpage loads, the web browser produces a Document Object Model (DOM) of the webpage,
and JavaScript can access all the elements of the webpage using the DOM API or methods like
document.getElementById, document.querySelector, etc

in HTML, the -------- indicates to the web browser how to display web pages, and --------- can provide
additional information about the HTML elements on a page

In HTML, the tags indicate to the web browser how to display web pages, and attributes can provide
additional information about the HTML elements on a page.

------ and ------- are the most proper and typical ways to begin and end a PHP block of code respectively

<?php** and **?> are the most proper and typical ways to begin and end a PHP block of code,
respectively.

PHP borrowed its syntax from two programming languages which are --------------- and --------------

PHP borrowed its syntax from two programming languages, which are C and Perl.

PHP stands for ---------------- while the PEAR in PHP stands for?

PHP stands for Hypertext Preprocessor, while PEAR in PHP stands for PHP Extension and Application
Repository.
the two main techniques to read and write a file in javascript are ----------- and -------------

The two main techniques to read and write a file in JavaScript are:

File API (for client-side operations, such as reading files in the browser using FileReader).

File System Module (fs) (for server-side operations in Node.js to read and write files).

readFile() and rs. writeFile() methods are used to read and write of a file using javascript

Does MySQL require a semicolon after each query ? TRue/False

True
MySQL requires a semicolon after each query to indicate the end of the statement.

is multiple inheritance supported in PHP? true/false

False
Multiple inheritance is not supported in PHP. However, PHP provides traits as a way to achieve similar
functionality.

------------- and ------------- are the fundamental categories of data types in Java script

Primitive types and non-primitive types.

-------------, -------------- and ------------ are the functions used to get the image's properties( width, size, and
height) in PHP?

getimagesize(), filesize(), and imagesx() are the functions used to get the image's properties (width,
size, and height) in PHP.
the keywords ---------, ------------- and ------------- are used in Javascript to handle exceptions

try, catch, and finally are the keywords used in JavaScript to handle exceptions.

the two major methods to submit form in php are -------------- and -------------

GET and POST are the two major methods to submit a form in PHP.

Javascript support the following three types of popup windows -----------, ------- and ------------

alert(), confirm(), and prompt() are the three types of popup windows supported by JavaScript.

in PHP, the two most fundamental constructs for printing to output are ------- and ------------

echo and print are the two most fundamental constructs for printing to output in PHP.

the ------------------ in Html is used to link another document on a website, and ---------- command is used
to delete the entire data in a table without disturbing the table definition in MySQL

The <a> tag in HTML is used to link another document on a website, and the TRUNCATE command is
used to delete the entire data in a table without disturbing the table definition in MySQL

SECTION B

1a. Variable Scope


Global variables can be accessed anywhere, while function-level variables are limited to the function
where they are declared.
Example:
javascript

Copy code

var globalVar = "I am global";

function scopeExample() {

let localVar = "I am local";

console.log(globalVar); // Accessible

console.log(localVar); // Accessible

console.log(localVar); // Error: Not defined

1b. Including JavaScript Code in HTML

 Using <script> tag within <head> or <body>.


Example:

html

Copy code

<script>

console.log("Hello, world!");

</script>

 Linking an external JavaScript file:

html

Copy code

<script src="script.js"></script>

1c. Function to Sum Even Numbers

javascript

Copy code

function sumEvenNumbers(arr) {

return arr.filter

(num => num % 2 === 0).reduce((sum, num) => sum + num, 0); }

yaml

Copy code
---

#### Question 2

2a. **Difference Between `==` and `===`**

- `==` compares values only (type conversion occurs).

- `===` compares values and types strictly.

Example:

```javascript

console.log(5 == '5'); // true

console.log(5 === '5'); // false

2b. Purpose of this


this refers to the object that is currently executing the function.
Example:

javascript

Copy code

const obj = {

name: "John",

greet() {

console.log(this.name); // "John"

},

};

obj.greet();

2c. Function to Return String Without Vowels

javascript

Copy code

function removeVowels(str) {

return str.replace(/[aeiouAEIOU]/g, '');

}
}

Question 3

3a. Components of PHP Function Definition

1. Function keyword.

2. Function name.

3. Parameters (optional).

4. Function body with return statement.


Example:

php

Copy code

function greet($name) {

return "Hello, " . $name;

3b. PHP Script for Greeting Based on Time

php

Copy code

date_default_timezone_set('Your/Timezone'); // Replace with your timezone

$hour = date("H");

if ($hour < 12) {

echo "Good Morning!";

} else if ($hour < 18) {

echo "Good Afternoon!";

} else {

echo "Good Evening!";

3c. Five Basic Data Types in PHP

1. String: "Hello, world!"

2. Integer: 42
3. Float: 3.14

4. Boolean: true or false

5. Array: ["apple", "banana", "cherry"]

You might also like