Flearn Website Header

PHP Study Cards


Click any card to reveal the answer

How do you start a PHP script?

click to flip

Answer:

Use opening tag <?php

How do you declare a variable in PHP?

click to flip

Answer:

Use dollar sign followed by variable name like $variable

How do you concatenate strings in PHP?

click to flip

Answer:

Use the dot operator like $str1 . $str2

How do you create an array in PHP?

click to flip

Answer:

Use array() function or square brackets like $arr = [1 2 3]

How do you access array elements in PHP?

click to flip

Answer:

Use square brackets with index like $arr[0]

How do you create an associative array in PHP?

click to flip

Answer:

Use key-value pairs like $arr = ['key' => 'value']

How do you include another PHP file?

click to flip

Answer:

Use include or require statements

What is the difference between include and require?

click to flip

Answer:

require stops execution if file not found include continues with warning

📢
Advertisement
See Your Advert Here!

How do you define a function in PHP?

click to flip

Answer:

Use function keyword like function myFunction() {}

How do you call a function in PHP?

click to flip

Answer:

Use function name followed by parentheses like myFunction()

How do you create a class in PHP?

click to flip

Answer:

Use class keyword like class MyClass {}

How do you create an object in PHP?

click to flip

Answer:

Use new keyword like $obj = new MyClass()

How do you access object properties?

click to flip

Answer:

Use arrow operator like $obj->property

How do you define constants in PHP?

click to flip

Answer:

Use define() function or const keyword

How do you handle errors in PHP?

click to flip

Answer:

Use try-catch blocks or error handling functions

How do you connect to MySQL database?

click to flip

Answer:

Use mysqli_connect() or PDO

📢
Advertisement
See Your Advert Here!

How do you execute SQL queries in PHP?

click to flip

Answer:

Use mysqli_query() or PDO prepare and execute methods

How do you get form data in PHP?

click to flip

Answer:

Use $_POST $_GET or $_REQUEST superglobals

How do you start a session in PHP?

click to flip

Answer:

Use session_start() function

How do you set session variables?

click to flip

Answer:

Use $_SESSION superglobal like $_SESSION['key'] = 'value'

How do you redirect in PHP?

click to flip

Answer:

Use header() function like header('Location: page.php')

How do you validate email in PHP?

click to flip

Answer:

Use filter_var() with FILTER_VALIDATE_EMAIL

How do you hash passwords in PHP?

click to flip

Answer:

Use password_hash() function

How do you verify hashed passwords?

click to flip

Answer:

Use password_verify() function

📢
Advertisement
See Your Advert Here!

How do you format dates in PHP?

click to flip

Answer:

Use date() function with format strings

How do you handle file uploads?

click to flip

Answer:

Use $_FILES superglobal and move_uploaded_file()

How do you read file contents in PHP?

click to flip

Answer:

Use file_get_contents() or fread() functions

How do you write to files in PHP?

click to flip

Answer:

Use file_put_contents() or fwrite() functions

How do you parse JSON in PHP?

click to flip

Answer:

Use json_decode() to convert JSON to PHP arrays or objects

How do you create JSON in PHP?

click to flip

Answer:

Use json_encode() to convert PHP data to JSON format

Remember: Use all available resources to study. Flearn alone cannot guarantee success in any exams—make sure to supplement your learning!