Jump to content

The Little Guy

Members
  • Posts

    6,675
  • Joined

  • Last visited

Everything posted by The Little Guy

  1. I like that one. I moved it to an online text file. http://ryannaddy.com/PHP%20Beginner.txt
  2. Thank you! New #17: 17. In what order are nested function calls evaluated? - Outer most function first * Inner most function first I dropped the "and lower" its php 5.4.x now How about this (I don't quite like "lists" or "collections"? 5. Which loop type is best used for arrays? - do ... while * foreach - while - for
  3. Thank you for all your feedback It's really helpful, and thanks for spell checking I think I got everyone's suggestions and fixed them! Well, I have re-worded many of the questions and replaced the "non-beginner" ones with jesirose's suggestion of "find/fix the error" questions and also fill in the blank. === The following questions are based on php 5.4.x and lower === 1. Assuming $var has a value of 0, which statements evaluate to true? * $var == false - !isset($var) - !empty($var) - $var === false 2. Which of the following does not belong? - echo "Hello, $first_name"; - echo <<<EOD Hello, $first_name EOD; * cout << "Hello, $first_name"; - print "Hello, $first_name"; 3. Which of the following is a valid variable (not property)? - var $var = 0; * $_ = 0; - $1 = 0; - $var:int = 0; 4. Which line will throw a syntax error? <?php $array = array(1,2,3); foreach($var in $array){ echo $var; } ?> - 1 - 2 * 3 - 4 - 5 - 6 5. Which loop type is intended for arrays? - do ... while * foreach - while - for 6. What is the correct way to define a function? - function myFunction(){} - define function myFunction(){} - function myFunction():void{} - $myFunction = function(){}; - Both A and C * Both A and D 7. What is the incorrect way to define an array? - $array = array(); - $array = []; * $array = new Array(); - Both B and C - All of the above 8. Which of the following methods is meant for variable debugging? - echo $my_var; echo $my_var1; - echo gettype($my_var); echo gettype($my_var1); * var_dump($my_var, $my_var1); 9. Which of the following is not a valid comment? * ' This is a comment - # This is a comment - /* This is a comment */ - // This is a comment 10. All statements must end with a semi-colon? * True - False 11. Blank lines out side of php blocks are fine before printing a header? - True * False 12. What is the value of $a on line 10? <?php $a = 1; function add(){ $b = 6; $a = 5; $a = $a + $b; return $a; } add(); echo $a; ?> - 11 - 6 * 1 - 5 13. Fill in the blank: <?php ______($_GET["year"]){ case 2000: case 2001: echo "2000 or 2001!"; break; case 2012: case 2013: echo "2012 or 2013!"; break; default: echo "Bad Date!"; break; } ?> - if - define - while * switch - declare 14. What what does a ternary statement look like? - if($i == 2){ $color = "red"; }else{ $color = "blue" } * $color = $i == 2 ? "red" : "blue"; - if($i == 2) $color = "red"; else $color = "blue"; 15. What does % (Modulus) do? - Returns the value after the decimal after division * Returns the remainder of a value after division - Just another way to divide two numbers - Returns the value before the decimal after division 16. What does 3 equal signs mean when comparing values? * Values must be the same value and same type - 3 equal signs is an error - 3 equal signs is the same as 2 17. When php reads functions with functions as parameters it reads: - From left to right - From right to left * From the middle out 18. Comparisons can be passed as parameters to a function? * True - False 19. What does "=>" (without the quotes) signify? - A pointer that points to a method/property in an object * Assigns a key to its value in an array - A comparison operator "equal to or greater than" - Both B and C 20. What does "->" (without the quotes) signify? * An operator that calls a method/property in an object - A pointer that points a key to its value from an array - A comparison operator "greater than zero" - Both B and C 21. What is the difference between "break" and "continue" within a loop? - "break" exits a loop and ends execution of the file; "continue" exits a loop and continues file execution - "break" pauses code execution for a short period; "continue" does not pause code execution * "break" exits a loop and continues; "continue", continues at the beginning of the loop - both "break" and "continue" exit a loop and continues the code execution 22. What does "goto" do? * Allows you to tell php to goto a particular label - Allows you to tell php to goto a particular line number - Allows you to tell php to goto a file for execution 23. What is missing? <?php $_SESSION["name"] = "Billy Joe"; echo $_SESSION["name"]; ?> - $_SESSION = new Session(); * session_start(); - header("Content-Type: text/html"); - define("$_SESSION", array()); 24. Does '"null" == null' evaluate to true or false? - True * False 25. How do you escape quotes within quotes? - echo "<a href=/"http://phpsnips.com/">PHP Snips</a>"; - echo '<a href="http://phpsnips.com">PHP Snips</a>'; * echo "<a href=\"http://phpsnips.com\">PHP Snips</a>"; - echo "<a href="http://phpsnips.com">PHP Snips</a>"; Thanks again!
  4. Okay, so I came up with 25 questions for the beginners test. Any suggestions on any of these? I would like to try an keep the test 25 - 30 questions long. Thanks for the input! === The following questions are based on php 5.4.x and lower === 1. Assuming $var has a value of 0, which statements evaluate to true? * $var == false - isset($var) - empty($var) - $var === false 2. Which of the following does not belong? - echo "Hello, $first_name"; - echo <<<EOD Hello, $first_name EOD; * cout << "Hello, $first_name"; - print "Hello, $first_name"; 3. Which of the following is a valid variable? - var $var = 0; * $_ = 0; - $1 = 0; - $var:int = 0; 4. What is the output of the following code: for($i = 0; var_dump(100), $i < 10; $i++); - An error - prints "100" 10 times - Nothing * prints "int(100)" 10 times 5. Which loop type is souly intended for arrays? - do ... while * foreach - while - for 6. What is the correct way to define a function? - function myFunction(){} - define function myFunction(){} - function myFunction():void{} - myFunction = function(){}; - Both A and C * Both A and D 7. What is the incorrect way to define an array? - $array = array(); - $array = []; * $array = new Array(); - Both B and C - All of the above 8. Which of the following methods is meant for variable debugging? - echo $my_var; echo $my_var1; - echo gettype($my_var); echo gettype($my_var1); * var_dump($my_var, $my_var1); 9. Which of the following is not a valid comment? * ' This is a comment - # This is a comment - /* This is a comment */ - // This is a comment 10. All statements must end with a semi-colon? * True - False 11. Blank lines out side of php blocks are fine before a header? - True * False 12. What is the value of $a on line 10? <?php $a = 1; function add(){ $b = 6; $a = 5; $a = $a + $b; return $a; } add(); echo $a; ?> - 11 - 6 * 1 - 5 13. What is the final output of this code? <?php $a = "hello"; $$a = "world"; echo "$a $hello"; ?> - hello $hello * hello world - An error ($hello is not defined) - An error (You can not have $$ as a variable) 14. What what does a ternary statement look like? - if($i == 2){ $color = "red"; }else{ $color = "blue" } * $color = $i == 2 ? "red" : "blue"; - if($i == 2) $color = "red"; else $color = "blue"; 15. What does Modulus do? - Returns the value after the decimal after division * Returns the remainder ofa value after division - Just another way to divide two numbers - Returns the value before the decimal after division 16. What does 3 equal signs mean when comparing values? * Values must be the same value and same type - 3 equal signs is an error - 3 equal signs is the same as 2 17. When php reads functions with functions as parameters it reads: - From left to right - From right to left * From the middle out 18. Comparisons can be passed as parameters to a function? * True - False 19. What does "=>" (without the quotes) signify? - A pointer that points to a method/property in an object * A pointer that points a key to its value from an array - A comparison operator "eqal to or greater than" - Both B and C 20. What does "->" (without the quotes) signiy? * A pointer that points to a method/property in an object - A pointer that points a key to its value from an array - A comparison operator "greater than zero" - Both B and C 21. What is the difference between "break" and "continue" within a loop? - break exits a loop and ends execution of the file; continue exits a loop and continues file execution - break pauses code execution for a short period; continue does not pause code execution * break exits a loop and continues; continue, continues at the beginning of the loop - both break and continue exit a loop and continue code execution 22. What does "goto" do? * Allows you to tell php to goto a particular label - Allows you to tell php to goto a particular line number - Allows you to tell php to goto a file for execution 23. What is the output on line 8? <?php function foo($x){ return function($y) use ($x){ return $y + $x; }; } $a1 = foo(10); echo $a1(2); ?> - 2 - 10 * 12 - 0 24. What is an Anonymous function? * A function that has no name - A function that is sometimes a function - A function that is also a vaiable - A function who's name is anonymous (function anonymous(){}) 25. How do you escape quotes withing quotes? - echo "<a href=/"http://phpsnips.com/">PHP Snips</a>"; - echo '<a href="http://phpsnips.com">PHP Snips</a>'; * echo "<a href=\"http://phpsnips.com\">PHP Snips</a>"; - echo "<a href="http://phpsnips.com">PHP Snips</a>";
  5. the ending ?> automatically terminates the line in the second one.
  6. <?php // Valid: while($i<10){} // Valid: echo "hello"; // Invalid: echo "hello" // Valid: for($i=0;$i<2;$i++){; echo "hello"; }; // Valid: echo "hello" ?>
  7. the question is meant to mean after: - constructs (loops, if/else) - includes - functions - last line of code before ?>
  8. Thanks for some of the questions, I have used a few of them! Here is one I added, not sure if it is too mean (trick question)... * = correct answer All lines MUST end with a semi-colon? - True * False
  9. I am going to be making tests for my site, right now I am building a list of questions. Does any have any input on some good questions to add? There will be 3 (maybe 4) PHP tests: - Beginner (structure / construct) - Intermediate (functions / classes) - Advanced (not sure atm) - Expert (Maybe) So, if anyone would like to add some questions, please let me know!
  10. Maybe I am blind, but where does the monitor go?
  11. Awesome! Im going to check that out, sounds interesting. I also noticed that you can see the smog from factories in the air and probably from other things as well but I just saw a image with smog, which is really kinda cool!
  12. I don't know if anyone has heard, but SimCity 2013 will be released this February! I will definitely be getting it! It allows for multi player where 2 people can build 2 cities together! It looks like you won't even have to "exit" your city and load theirs, as you will be playing side by side where you can view both cities at all times (if that makes sense)! I am excited to see what other new things will be in the game! I also hear that traffic is in "real time" so you can actually see where heavy traffic is/isn't, unlike the previous simcity games. So, does anyone else play these types of games or are even thinking about getting the game?
  13. I couldn't get php-fpm, I tried searching for it, but nothing for windows. Apache I used: mod_php Nginx I used: c:\php\php-cgi.exe -b 127.0.0.1:9000 -c c:\php
  14. So, I posted my first blog post ever entitled "Nginx vs. Apache"! http://blog.phpsnips.com/?p=22 I was hoping I could get your guys' thoughts on the post. The post isn't really too original, but its a starting point!
  15. Me too... I guess I would have to say the Billboard 100 as well, and sirusXM Hits1. But also: Flogging Molly Disturbed Three Days Grace Seether Porn Star Dancing (song)
  16. If you are using php 5.4 session_register() was removed, 5.3 it was deprecated. I also see that you are not connecting to a database but trying to do a query.
  17. That is how you know someone still uses notepad to edit
  18. I have just recently started using spaces for tabbing... I use K&R Variant: 1TBS Here is a small list: http://en.wikipedia.org/wiki/Indent_style
  19. They could take a guess based on: HTTP_ACCEPT_LANGUAGE
  20. according to the way you posted, you have white space above <?php
  21. I had a similar idea a few months back.....
  22. go to the table structure and click the edit button for the column, in there you can change it.
  23. if you have access to the config file; ft_min_word_len = 3
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.