๐น PHP Basic Flashcards
๐น PHP Basic Flashcards – Set 1
| ๐งพ Question | ๐ก Answer |
|---|---|
| What is PHP? | A server-side scripting language for web development. |
| Why is PHP used? | To build dynamic websites, handle forms, sessions, and databases. |
| Key features of PHP? | Open-source, server-side, platform-independent, supports databases. |
echo vs print? | echo is faster; print returns 1 and can be used in expressions. |
| How to declare a variable? | Use $ symbol. Example: $name = "John"; |
| PHP data types? | String, Integer, Float, Boolean, Array, Object, NULL. |
== vs ===? | == checks value, === checks value + type. |
| What are superglobals? | Built-in variables like $_GET, $_POST, $_SESSION, etc. |
| GET vs POST method? | GET shows data in URL; POST hides data. POST is more secure. |
include vs require? | require halts on error; include only gives a warning. |
๐น Flashcards – Set 2
| ๐งพ Question | ๐ก Answer |
|---|---|
isset() vs empty()? | isset() checks if variable exists, empty() checks if it's empty. |
| Single vs Double Quotes? | 'text' = literal, "text $var" = parses variable. |
| Define a constant? | define("SITE_NAME", "MySite"); |
| Array types? | Indexed, Associative, Multidimensional. |
| Indexed vs Associative array? | Indexed uses numbers, associative uses keys. |
| Loop through an array? | Use foreach($arr as $val) or a for loop. |
| Loop types in PHP? | for, while, do...while, foreach. |
| Define a function? | function greet() { echo "Hi"; } |
| Handle errors in PHP? | Use error_reporting(), try-catch, or die() |
| Start a session? | Use session_start(); |
๐น Set 3 (Cookies, Sessions, Misc.)
| ๐งพ Question | ๐ก Answer |
|---|---|
| Cookies vs Sessions? | Cookies = browser; Sessions = server (more secure). |
| Latest version of PHP? | You can say "PHP 8.x" depending on interview timing. |
| Write a simple PHP script? | |
Use of die() or exit()? | Stops the script with a custom message. |
Comments
Post a Comment