๐Ÿ”น 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?
 <?php echo "Hello, world!"; ?>

Use of die() or exit()?
Stops the script with a custom message.

Comments

Popular posts from this blog

PHP INTERVIEW QUESTIONS

PHP Intermediate Questions Interview Preparation

PHP Interview Questions (Beginner Level) – Short Answers