Question

# After the if statement that follows is executed, what will the value of $discount_amount be?...

#
After the if statement that follows is executed, what will the value of $discount_amount be?

$discount_amount;
$order_total = 200;
if ($order_total > 200) {
$discount_amount = $order_total * .3;
} else if ($order_total > 100) {
$discount_amount = $order_total * .2;
} else {
$discount_amount = $order_total * .1;
}

       
2

       
20

       
40

       
60

#

To open a file in PHP, you use the _________ function.

       
fopen()

       
fputs()

       
open()

       
fp()

#

Which of the following is an alias for the chop() PHP function?

       
trim()

       
ltrim()

       
rtrim()

       
\0

2 points   

#
The _____ function splits a string into an indexed array.

       
repair()

       
explode()

       
implode()

       
strtok()

#

When you use the substr() function to extract a substring from a string, you need to at least pass an argument that gives

       
the characters in the substring that you are looking for.

       
the starting position of the substring.

       
the length of the substring

       
the separators for the substring.

#

A PHP variable name ________________________.

       
can contain special characters

       
is case senstive

       
can be a PHP reserved word

       
can start with a letter, a digit, or two underscores

#

A(n) __________ operator requires a single operand either before or after the operator.

       
unary

       
single

       
binary

       
ternary

2 points   
#

The __________ operator divides one operand by another operand and returns the remainder.

       
addition

       
subtraction

       
division

       
modulus

#

Which of the following is a PHP statement that allows you to load a file into your PHP script?

       
#include

       
require()

       
main()

       
#require

#

The value of the __________ attribute identifies the program on the Web server that will process the form data when the form is submitted.

       
action

       
method

       
name

       
id

#

The expression $test = substr_replace($test, 'X', -1); replaces:

       
The second character in $test

       
The last character in $test

       
The first character in $test

       
The entire $test string

de code that changes the value used the by the condition expression, your program will be caught in a __________ loop.

       
continuous

       
continuing

       
constant

       
infinite

#
Which of the following statements is true concerning PHP functions?

       
PHP function names cannot begin with a digit.

       
PHP functions can have the same name as an existing function.

       
PHP functions must include parameters.

       
PHP function names can contain only letters, digits, and underscores.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

After the if statement that follows is executed, what will the value of $discount_amount be?

$discount_amount;
$order_total = 200;
if ($order_total > 200) { //it returns false
$discount_amount = $order_total * .3;
} else if ($order_total > 100) {
$discount_amount = $order_total * .2;
} else {
$discount_amount = $order_total * .1;
}

Ans. initially discount value is null and order_total value is 200

for the first loop it will check that order_total value is greater than 200 which return false

for the second loop 200>100 is true so this loop will execute

so discount_amount=200*.2=40.0

ANS is 40

2.

To open a file in PHP, you use the _________ function.

Ans . to open a file in we should use fopen() function .

fputs() was used to write into the file while there are no function with name open() and fp() in php

so right answer is fopen()

3.  Which of the following is an alias for the chop() PHP function?

chop function is used to remove the white spaces from the String from the right side of the string which is almost same as working of right trim so we can call it as rtrim() function as a alias for the chop .

So answer is rtrim()

4. The _____ function splits a string into an indexed array.

in php we generally use explode() function to split a string based on the certain condition which we can say that we can split based on the different symobols in the String

for e.g $s="hello,how,are,you"

if we use explode(",",$s); it will result into hello at 0 how at 1 are at 2 you at 3 index in the array .

Answer is explode()

5. When you use the substr() function to extract a substring from a string, you need to at least pass an argument that gives

Ans . whenever we are using the substr() function we must have to give the starting position of the String which tells the compliler.interpreter that from which part of the string we want the substring portion so it is must to give the starting position of the substring.

Ans. the starting position of the substring.

6. A PHP variable name ________________________.

In php we canot allow use of special character as a variable name and it is not a reserver keyword in php.

while php variable are case sensitive meanse while allocating the variable we have to carefully give their name in lower case or upper case whatever we want.

Ans. variable are case sensitive

7.The __________ operator divides one operand by another operand and returns the remainder

Addition operator simply add the two operand and returns the sum.

Substraction operator simply subtract two operand and returns the differecne.

Division operator divides the two operand and return the divident.

modulus( %) operator divide the two operand and returns the remainder

Ans . modulus

8. Which of the following is a PHP statement that allows you to load a file into your PHP script?

Ans. there is no main() function in php which can load file. Howerver we can load file by using include and require keyword not by #include but by using include (file name) so this option is wrong

But we can use require() to load a file into the php script

Ans. require()

9. The value of the __________ attribute identifies the program on the Web server that will process the form data when the form is submitted.

Ans . Action was used in php when we should submit the form based on ceratin actions and sent it to other depending upon action attribute so this option was wrong.

name and id are used to represent the particular attribute so these are also wrong

but method atribute identifies the program on the web server that will process the form data after sucessfully submission.

Ans. Method.

10. The expression $test = substr_replace($test, 'X', -1); replaces:

the substr_replace replaces the one string from other string

here negative indicates from the end of the string.

negative number are used to iterate the string from backward.

Ans The last character in $test

Ans. The last character in $test

11. code that changes the value used the by the condition expression, your program will be caught in a __________ loop.

Ans continuous loop is responsible for caughting our program

In Infinite condition loop will execute infinte times which will never terminate

Constant loop will execute till amount terms like 10,20 etc.

12. Which of the following statements is true concerning PHP functions?

Ans . option 2,3 are totally wrong because we can create our own function and it is not compulsory that we can give arguements to php function we can give empty arguements also.

functions canot begin with digit.

Ans . PHP function names cannot begin with a digit.

Add a comment
Know the answer?
Add Answer to:
# After the if statement that follows is executed, what will the value of $discount_amount be?...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • 11. The str_word_count() function returns the number of digits in a string. T/F [?] 12. The...

    11. The str_word_count() function returns the number of digits in a string. T/F [?] 12. The term parsing refers to the act of dividing a string into logical component substrings or tokens. T/F [?] 13. The strpos() function performs a case-sensitive search for specified characters in a string and returns the position of the first occurrence of a substring within a string. T/F [?] 14. The strchr() function or strrchr() function return a substring from the specified characters to the...

  • Here is the UML for the class Contact -fullName : string -phoneNum: string -emailAddress : string...

    Here is the UML for the class Contact -fullName : string -phoneNum: string -emailAddress : string +Contact()                     //default constructor sets all attribute strings to “unknown”; no other constructor +setName(string name) : void +setPhone(string pn) : void +setEmail(string em) : void +getName() : string +getPhone() : string +getEmail() : string +printContact() : void         //print out the name, phone numbers and email address Create New Project Name your project: CIS247_Lab7_YourLastName. For this exercise, you may use a header file or one file...

  • Objectives You will implement and test a class called MyString. Each MyString object keeps track ...

    Objectives You will implement and test a class called MyString. Each MyString object keeps track of a sequence of characters, similar to the standard C++ string class but with fewer operations. The objectives of this programming assignment are as follows. Ensure that you can write a class that uses dynamic memory to store a sequence whose length is unspecified. (Keep in mind that if you were actually writing a program that needs a string, you would use the C++ standard...

  • 0. Introduction. This involves designing a perfect hash function for a small set of strings. It...

    0. Introduction. This involves designing a perfect hash function for a small set of strings. It demonstrates that if the set of possible keys is small, then a perfect hash function need not be hard to design, or hard to understand. 1. Theory. A hash table is an array that associates keys with values. A hash function takes a key as its argument, and returns an index in the array. The object that appears at the index is the key’s...

  • (c programming): write a program that contains a function named getName, that does not get any...

    (c programming): write a program that contains a function named getName, that does not get any parameter and returns a character array of a random name from a constant list of 30 names, in a global array. the function returns that random name. each name in the list is a character string that consists of not more than 20 characters(not including finishing 0). the name consists of only characters from the american alphabet (a-zA-Z) and does not contain any "white"...

  • In C Write a function that asks for the user's first, middle, and last names. The...

    In C Write a function that asks for the user's first, middle, and last names. The names will be entered by the user on a single line and will be stored in three different C-strings. The program should then store, in a fourth array, the name arranged in the following manner: the last name followed by a comma and a space, followed by the first name and a space, followed by the middle name. For example, if the user entered...

  • Time.cpp: #include "Time.h" #include <iostream> using namespace std; Time::Time(string time) {    hours = 0;   ...

    Time.cpp: #include "Time.h" #include <iostream> using namespace std; Time::Time(string time) {    hours = 0;    minutes = 0;    isAfternoon = false;    //check to make sure there are 5 characters    if (//condition to check if length of string is wrong)    {        cout << "You must enter a valid military time in the format 00:00" << endl;    }    else    {        //check to make sure the colon is in the correct...

  • JAVA: Run length encoding is a simple form of data compression. It replaces long sequences of...

    JAVA: Run length encoding is a simple form of data compression. It replaces long sequences of a repeated value with one occurrence of the value and a count of how many times to repeat it. This works reasonably well when there are lots of long repeats such as in black and white images. To avoid having to represent non-repeated runs with a count of 1 and the value, a special value is often used to indicate a run and everything...

  • C++ language only. Thank you C++ language (cout <). NO atoi function. And please pay attention...

    C++ language only. Thank you C++ language (cout <). NO atoi function. And please pay attention to the rules at the bottom. Extra good rating to whoever can help me with this. TIA. In certain programming situations, such as getting information from web forms, via text boxes, the data coming in may need to be numerical (we want to perform arithmetic on it), but it is stored in the form of a list of characters (the numerical value stored is...

  • In C++, You are given a file of customer data with records in the following format...

    In C++, You are given a file of customer data with records in the following format : account number, last name, first name, middle name. Write a program to convert the input data and display it to the monitor in the following format : Accout Name     Logon ID Initial Pswd 21-88282712-B Keith S. Adams ADAM21 Adam88282 08-36847734-A John R. Sturm STUR08 Stur36847    etc. Notes :     1) The account number on the input is 10 digits     2)  The names on...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT