Interview Questions and Answers (Simple English)
Q: What is PHP?
A: PHP (Hypertext Preprocessor) is a server-side scripting language used to build dynamic websites
and web applications.
Q: How to handle form submission in PHP?
A: HTML Form:
<form action="submit.php" method="POST">
Name: <input type="text" name="name">
<input type="submit">
</form>
PHP Script (submit.php):
<?php
$name = $_POST['name'];
echo "Hello, $name!";
?>
Q: What is the difference between Session and Cookie in PHP?
A: - Session is stored on the server.
- Cookie is stored on the client/browser.
Q: How to connect PHP with MySQL?
A: <?php
$conn = mysqli_connect("localhost", "root", "", "test_db");
if (!$conn) {
die("Connection failed: " . mysqli_connect_error());
}
echo "Connected successfully";
?>
Q: How to securely store passwords in PHP?
A: <?php
$password = "mySecret";
$hashedPassword = password_hash($password, PASSWORD_DEFAULT);
echo $hashedPassword;
?>
Q: Difference between var, let, and const in JavaScript?
A: - var: function scoped
- let: block scoped
- const: block scoped and immutable
Q: What is an Arrow Function in JavaScript?
A: const add = (a, b) => a + b;
console.log(add(2, 3)); // 5
Q: What is Event Bubbling and Delegation?
A: - Event Bubbling: Events move from inner to outer elements.
- Event Delegation: Attach event to parent to manage child events.
Q: What is JSX in React?
A: JSX is a syntax extension that lets you write HTML inside JavaScript in React.
Example: const element = <h1>Hello, world!</h1>;
Q: Difference between State and Props in React?
A: Props:
- Come from parent
- Immutable
State:
- Managed inside component
- Mutable
Q: How to use useState and useEffect in React?
A: import { useState, useEffect } from 'react';
function App() {
const [count, setCount] = useState(0);
useEffect(() => {
console.log("Component Mounted or Updated");
}, [count]);
return (
<button onClick={() => setCount(count + 1)}>
Count: {count}
</button>
);
Q: Difference between Primary Key and Foreign Key in MySQL?
A: - Primary Key: Unique identifier for a table.
- Foreign Key: Refers to Primary Key of another table.
Q: How to write a SELECT query in MySQL?
A: SELECT * FROM users WHERE age > 18;
Q: Difference between Tailwind CSS and Bootstrap?
A: - Tailwind: Utility-first CSS framework.
- Bootstrap: Component-based CSS framework.
Q: Difference between Theme and Plugin in WordPress?
A: - Theme: Controls website design.
- Plugin: Adds extra functionality.