PHP Cheat Sheet 2026

The 30 highest-yield PHP facts, distilled from real exam questions. Print it, save it as a PDF, or study it here — free, no sign-up.

70 questions
90 min time limit
70.00% to pass
  1. What does the abstract keyword mean when applied to a PHP class? The class cannot be instantiated directly
  2. Isn't it true/false that all variables in PHP begin with a $(dollar) sign? B) True
  3. Which PHP magic method defines how an object behaves when cast to a string? __toString()
  4. Is it possible to run PHP from the command line? Yes
  5. Which superglobal holds data submitted via an HTML form using the POST method? $_POST
  6. What is the primary value of case study analysis in PHP Programming Language training? Developing critical thinking by applying theory to realistic professional scenarios
  7. What is the recommended technique for preventing CSRF attacks in PHP form submissions? Generate and validate unique per-session CSRF tokens in every form
  8. Which loop in PHP is guaranteed to execute its body at least once? do-while
  9. Is it true/false that once a variable is declared, it can only be used once in the PHP source code? A) False
  10. What does PDO::rollBack() do in PHP? Undoes all changes made since the transaction began
  11. What is a risk mitigation strategy in PHP Programming Language practice? Implementing controls that reduce the likelihood or impact of identified risks
  12. Which keyword is used to define a class in PHP? class
  13. What does PDOStatement::rowCount() return after a SELECT query in most databases? An unpredictable or zero value (behavior varies by driver)
  14. Which PHP session configuration setting helps mitigate session hijacking via XSS attacks? session.cookie_httponly = 1
  15. What is late static binding in PHP accessed through? static::
  16. To create a CURL session, which of the following functions will be used? Curl_init()
  17. Which keyword allows calling a PHP method without creating a class instance? static
  18. How do PHP professionals build trust with clients or stakeholders? Through consistent competence, transparency, reliability, and ethical behavior
  19. Which function will you use to quickly transform an HTML page into a database-friendly format? Htmlentities()
  20. PHP 5.3.0 introduces a new functionality that allows you to refer to a called class in a static inheritance context. What's the name of it? Late static bindings
  21. What is the benefit of interdisciplinary collaboration in PHP Programming Language practice? It brings diverse expertise and perspectives that improve outcomes and innovation
  22. What is the name of the special method automatically called when an object is created in PHP? __construct()
  23. How do PHP professionals evaluate research quality? By assessing methodology, sample size, peer review status, and relevance to practice
  24. What does an interface in PHP define? A contract of methods that implementing classes must define
  25. Which PDO method binds a PHP variable to a named placeholder, passing by reference? bindParam()
  26. Which of the following methods for declaring a PHP variable is incorrect? $a_Number = 9
  27. The syntax of PHP is most similar to: Perl and C
  28. What is the purpose of PHP's filter_var() and filter_input() functions in secure development? To validate and sanitize user input using predefined filter constants
  29. What data type will PHP convert the following variable to automatically:? $aVariable = 99; B) Integer (a number variable)
  30. Which PHP function converts special characters to HTML entities to prevent XSS attacks? htmlspecialchars()
Turn these facts into recall: