Logo/

PHP Basics Flashcards

Log in

Made with ScholarlyMake flashcards like these from your own notes

PHP Basics Flashcards

Questions and answers

50 cards
  1. Question:What operator is used to concatenate two strings in PHP?

    Answer:The . operator

  2. Question:How do you add a space between concatenated strings using the . operator?

    Answer:By inserting " " between the strings

  3. Question:What is a simpler way to concatenate strings with a space using double quotes?

    Answer:Surround variables in double quotes with space: "$x $y"

  4. Question:What function is used for slicing a string in PHP?

    Answer:substr()

  5. Question:What are the parameters for the substr() function?

    Answer:Start index and length (number of characters)

  6. Question:What does the index start from in PHP strings?

    Answer:0 for the first character

  7. Question:How do you slice a string to the end using substr()?

    Answer:Omit the length parameter

  8. Question:How are negative indices used in substr() for slicing from the end?

    Answer:Negative values count backwards from the end (-1 is last character)

  9. Question:What does a negative length in substr() do?

    Answer:Omits characters from the end

  10. Question:What is an escape character in PHP strings?

    Answer:A backslash \ followed by the character to insert

  11. Question:How do you escape a double quote inside a double-quoted string?

    Answer:Use \"

  12. Question:What are some common escape sequences in PHP?

    Answer:\' for single quote, \" for double quote, \$ for variables, \n for new line

  13. Question:What are the three main numeric types in PHP?

    Answer:Integer, Float, Number Strings

  14. Question:How are numeric variables created in PHP?

    Answer:By assigning a numeric value to them

  15. Question:What function verifies the type of a variable in PHP?

    Answer:var_dump()

  16. Question:What is an integer in PHP?

    Answer:A non-decimal number between certain limits (e.g., -2147483648 to 2147483647 in 32-bit)

  17. Question:What happens if a number exceeds integer limits in PHP?

    Answer:It is stored as a float

  18. Question:What are the rules for integers in PHP?

    Answer:At least one digit, no decimal point, can be positive or negative

  19. Question:What formats can integers be specified in PHP?

    Answer:Decimal (base 10), hexadecimal (0x), octal (0), binary (0b)

  20. Question:What PHP constant represents the largest integer?

    Answer:PHP_INT_MAX

  21. Question:What functions check if a variable is an integer in PHP?

    Answer:is_int(), is_integer() (alias), is_long() (alias)

  22. Question:What is a float in PHP?

    Answer:A number with a decimal point or in exponential form

  23. Question:What is the maximum precision for floats in PHP?

    Answer:14 digits

  24. Question:What PHP constant is the largest representable float?

    Answer:PHP_FLOAT_MAX

  25. Question:What functions check if a variable is a float in PHP?

    Answer:is_float(), is_double() (alias)

  26. Question:What does PHP stand for?

    Answer:PHP: Hypertext Preprocessor

  27. Question:Where are PHP scripts executed?

    Answer:On the server

  28. Question:What file extension do PHP files have?

    Answer:.php

  29. Question:What can PHP do with files on the server?

    Answer:Create, open, read, write, delete, and close them

  30. Question:Why is PHP popular?

    Answer:Runs on various platforms, compatible with many servers, supports wide range of databases

  31. Question:How does a PHP script start and end?

    Answer:<?php and ?>

  32. Question:What ends PHP statements?

    Answer:A semicolon (; )

  33. Question:What is the echo statement used for in PHP?

    Answer:To output text to the browser

  34. Question:Are PHP keywords case-sensitive?

    Answer:No, keywords like if, echo are not case-sensitive

  35. Question:Are PHP variable names case-sensitive?

    Answer:Yes, $color differs from $Color

  36. Question:What is the purpose of comments in PHP?

    Answer:To explain code, remind of logic, or temporarily disable parts

  37. Question:How do you write a single-line comment in PHP?

    Answer:Using // or #

  38. Question:How do you write a multi-line comment in PHP?

    Answer:Using /* and */

  39. Question:What is the result of concatenating "Hello" and "World" without space?

    Answer:HelloWorld

  40. Question:What does substr($x, 6, 5) return for $x = "Hello World!"?

    Answer:World

  41. Question:What does substr($x, -5, 3) return for $x = "Hello World!"?

    Answer:rld

  42. Question:What does substr($x, 5, -3) return for $x = "Hi, how are you?"?

    Answer:ow are y

  43. Question:What is the range for integers in 32-bit PHP systems?

    Answer:-2147483648 to 2147483647

  44. Question:Why is 4 * 2.5 stored as float in PHP?

    Answer:Because one operand is a float

  45. Question:What is PHP_INT_SIZE?

    Answer:The size of an integer in bytes

  46. Question:What is an example of a float in exponential form?

    Answer:7.64E+5

  47. Question:What can PHP output besides HTML?

    Answer:Images, PDF files, XHTML, XML

  48. Question:What is a simple PHP file structure?

    Answer:Contains HTML tags and PHP code between <?php ?>

  49. Question:In the example, why does only $color display value?

    Answer:Because variables are case-sensitive

  50. Question:Where can a single-line comment be placed?

    Answer:Before or at the end of a line