Help with PHP quiz

They say I can use google for the answers on this quiz. I really know zero PHP. Can anyone help? I can only answer one question :-[

// DIRECTIONS
// This is a simple PHP test. These are not trick questions, just simple logic.
// Do the best you can. Google whatever, test whatever. Good luck!

// code for question #1
$var1 = 10;
$var2 = 20;
$var2 = $var1;

//********************
// Question #1
//********************

// What is the value of $var1 and $var2?
// $var1 =
// $var2 =

// Code for question #2, #3 and #4
$string = " peaceful VALLEY ";
$string = ucwords(strtolower(trim($string));

//********************
// Question #2
//********************

// This code gives the following error, please tell me what I did wrong.
// Parse error: syntax error, unexpected ‘;’ in - on line 23

// Answer:  Extra "("

//********************
// Question #3
//********************

// If this code worked, what do the 3 functions on line 23 do? Please list in order of operations.

// Answer: 

//********************
// Question #4
//********************

// Is strtolower() even needed? What is my logic for using it?

// Answer: 

// Code for question #5
$int = 0;
if(!empty($int)) {
$int = 1;
}

//********************
// Question #5
//********************

// What is the value of $int?
// $int =

im confused?

what you need help with ?

the questions are found in the code. There are 5 questions.

Hello,

I’m guessing you want the answers to the questions in order to pass your quiz or whatever. I’ll list the answers for you; however, if you want to know why the answers are the way they are, tell me and I’ll explain it to you.

  1. $var1 is 10 and $var2 is 10
  2. You must add a “)” at the end before the “;”
  3. Trim will get rid of the spacing at the beginning and end of the string, strtolower will then lowercase all characters in the string, finally ucwords will then capitalize the first character of each word in the string.
  4. Because the word VALLEY is in all caps, you will need to use strtolower to lowercase the word before you capitalize the “V”.
  5. $int is 0

Please note at all of these answers could have been found on google if you worded the search correctly. But these answers should be what you are looking for.

Cheers!

sorry one question…

so in php if i have this code
[php]
$hello = function1(function2(function3(“Hello world”)));
[/php]
it will be executed function3 then function2 and last function1?
like the function closer to the parameter runs first ?

Thanks! I did try some googling but with not such great luck. I very much appreciate the help!

Hello,

Wilson look at your code realistically. Function1 will take in its parameter of function2(function3(“Hello World”). The parameter is the syntax of two other functions. The same with the other two functions. In order for function1() to use it’s parameter, PHP will have to perform any function that is in the function’s parameter. Thus with this logic, function3 will be the first function that will be performed followed by function2() and then function1().

I hope I explained my reasoning so you can understand.

Cheers!

yes you explained well

now thanks to you i know how php execute multiple function

Sponsor our Newsletter | Privacy Policy | Terms of Service