3.E: Scripting Language (Exercises)
- Page ID
- 3695
\( \newcommand{\vecs}[1]{\overset { \scriptstyle \rightharpoonup} {\mathbf{#1}} } \) \( \newcommand{\vecd}[1]{\overset{-\!-\!\rightharpoonup}{\vphantom{a}\smash {#1}}} \)\(\newcommand{\id}{\mathrm{id}}\) \( \newcommand{\Span}{\mathrm{span}}\) \( \newcommand{\kernel}{\mathrm{null}\,}\) \( \newcommand{\range}{\mathrm{range}\,}\) \( \newcommand{\RealPart}{\mathrm{Re}}\) \( \newcommand{\ImaginaryPart}{\mathrm{Im}}\) \( \newcommand{\Argument}{\mathrm{Arg}}\) \( \newcommand{\norm}[1]{\| #1 \|}\) \( \newcommand{\inner}[2]{\langle #1, #2 \rangle}\) \( \newcommand{\Span}{\mathrm{span}}\) \(\newcommand{\id}{\mathrm{id}}\) \( \newcommand{\Span}{\mathrm{span}}\) \( \newcommand{\kernel}{\mathrm{null}\,}\) \( \newcommand{\range}{\mathrm{range}\,}\) \( \newcommand{\RealPart}{\mathrm{Re}}\) \( \newcommand{\ImaginaryPart}{\mathrm{Im}}\) \( \newcommand{\Argument}{\mathrm{Arg}}\) \( \newcommand{\norm}[1]{\| #1 \|}\) \( \newcommand{\inner}[2]{\langle #1, #2 \rangle}\) \( \newcommand{\Span}{\mathrm{span}}\)\(\newcommand{\AA}{\unicode[.8,0]{x212B}}\)
Your First PHP
- Comment your name and assignment number at the top of the file.
- Create a variable that contains the current date and time.
- Create a constant that contains the assignment title.
- Make the assignment title the title of the page using the constant.
- Output the date and time.
- Output the PHP version, and server operating system (use system references).
- Display the following string as shown:
- Chicken finger subs are the best!” said Clyde.
- “I agree”, said Bill, “but only when they are extra hot.”
- Calculate and display the following. Use variables for each value used in the equation:
- 8 + 9 = 17
- 24 % 8 = 0
- 5 / 3 = 1.667
Forms and More
- Create a website which presents the user with a registration form for a subscription service. Your form should request the following information:
- First, last name
- Occupation
- Email address
- Mailing address
- Phone
- Job Title
- All information should be hidden (i.e., not be shown in the address bar).
- Name, email, and mailing address fields should be required.
- When completed, the form values are stored in a unique text file for each submission.
- The user should see a confirmation that their submission was received.
What Time Is It?
- Create an HTML page and complete the following with JavaScript only.
- Output the current date and time to the screen.
- Convert local time and date to UTC and display the result.
- Add a button to your page that updates these times.
Let’s Play A Game!
- Create a page with a 3 by 3 grid to represent a tic-tac-toe board.
- Using jQuery, assign an X or O (alternating back and forth) when a cell is clicked on.
- Include a button to reset the board after a game.
- Using canvas, put a colorful gradient of the words Tic-Tac-Toe at the top of the page.
Discussion / Written Response
- How are tags in XML different from tags in HTML?
- hat is the difference between single and double quoted strings in PHP?
- What is the difference between server side and client side scripting? What are good situations to use each?
- What is the difference between GET and POST?
- Describe the difference between notice, warning, and critical error messages in PHP.
- Describe the difference between include, require, and require once.
Section 3 Questions
- The array $array = ("One"=>1, "Two"=>2, "Three"=>3) is numeric
a. True
b. False- Answer
- b
- Which equation equates to 14?
a. 4 + 5 2 - 4
b. (4 + 5) 2 – 4
c. 4 + 5 (2 - 4)
d. 4 + (5 2) – 4- Answer
- b
- The foreach() function in PHP is used when dealing with:
a. Strings
b. Arrays
c. Objects
d. Lists- Answer
- b
- Which PHP reserved array holds values passed in the URL?
a. $_POST
b. $_GET
c. $_SESSION
d. None of these- Answer
- b
- Which of the following is NOT a valid variable name?
a. $variable
b. $string
c. $_string1
d. $and-then- Answer
- d
- Which of the following is an incorrect definition?
a. Apache = Web Server
b. PHP = Object oriented language
c. MySQL = Database Server
d. HTML = Operating System- Answer
- d
- Which of the following PHP functions runs until a condition is met?
a. foreach()
b. while()
c. during()
d. None of these- Answer
- b
- Declaring strings using single quotes means PHP syntax in the string will be shown.
a. True
b. False- Answer
- a
- Which HTML element is used for JavaScript?
a. <scripting>
b. <javascript>
c. <jscript>
d. <script>- Answer
- d
- Where can we place JavaScript?
a. <head>
b. <body>
c. A & B
d. None of these- Answer
- c
- JavaScript and Java are the same thing.
a. True
b. False- Answer
- b
- DOM stands for
a. Document Object Model
b. Document Oriented Media
c. Document Object Manager
d. None of these- Answer
- a
- When a user views a page containing a JavaScript program, which machine actually executes the script?
a. The user’s browser
b. The Web server
c. Both
d. None of the above- Answer
- a
- Which of the following cannot be done with JavaScript?
a. Validating a form
b. Sending a form’s contents by email
c. Storing the form’s contents to a database file on the server
d. None of the above- Answer
- b
- Which of the following is not a valid JavaScript variable name?
a. 1stname
b. _firstName
c. FirstName
d. None of these- Answer
- a
- What is the correct JavaScript syntax to write “Hello World”?
a. System.out.println("Hello World")
b. println ("Hello World")
c.document.write("Hello World")
d. response.write("Hello World")- Answer
- c
- jQuery uses CSS selectors to interact with page elements.
a. True
b. False- Answer
- a
- In jQuery, $(‘div’) would select
a. The first div element
b. All div elements
c. An element named div- Answer
- b
- Which jQuery function makes sure the contained code only runs when the page is done loading?
a. $(body).onload()
b. $(document).loaded()
c. $document.ready()
d. None of these- Answer
- c
- jQuery is an add-on library for JavaScript, not an independent language.
a. True
b. False- Answer
- a