Cracking PHP Interviews : 80+ Question and Answers

Why take this course?
-
Aggregation: A form of association where one class holds a reference to another object of which it is a member. It represents "has-a" relationship but with the implication that the lifetimes of the two objects are independent.
-
Composition: A form of association that is similar to aggregation, but the relationship is stronger (the "has-a" part). The composed object becomes an integral part of the aggregate, often with its lifetime tied to that of the container class. In other words, when the container object is destroyed, its constituent objects are also destroyed.
-
Association: A relationship between two classes in which each class has a reference to the other but neither class owns or controls the lifecycle of the other. It represents a "has-a" or "part-of" relationship where both sides are independent of one another.
-
Abstraction: The concept of hiding the complex reality while exposing only the necessary parts. It is a way of creating a simple model of an object that represents its essential features without including the details.
-
Encapsulation: The principle of bundling data with the methods that operate on that data, or the restricting of direct access to some of an object's components. Encapsulation serves to keep implementation details private and hidden from the outside world.
-
Inheritance: A mechanism where a class derives fields and methods from another class. The class that inherits is called a subclass (or derived class), and the class being inherited from is called the superclass (or base class).
-
Super class: This is the class being extended or inherited from by the subclass. It provides the common properties and behaviors to its subclasses.
-
Sub class: A class that inherits from another class, often overriding, adding, or modifying the methods and properties it inherits.
-
Inherit a class in PHP: You can inherit a class by using the
extends
keyword followed by the name of the parent class. -
Constructor: A special method in a class that is called when an object is created. Its primary purpose is to initialize the newly created object by allocating resources and setting initial state. In PHP, constructors are defined with the
__construct()
method. -
__construct()
: This method is automatically called right after an object is instantiated. You can pass arguments to it, which allows for a custom initialization process. -
Destructor: A special method in a class that is called when an object is destroyed. It's used to release resources held by the object and perform any cleanup necessary. In PHP, destructors are defined with the
__destruct()
method. -
Autoloading classes in PHP: PHP provides a function called
spl_autoload_register()
which allows you to register autoloaders that will be called when a class is used that hasn't been included or required yet. -
Die(): A function that terminates the current script and displays an optional message, then exits with the EXIT_CODE constant (defaulting to 1).
-
Variable variables: In PHP, you can use variables to reference other variables. For example,
$$varName
will hold the value of whatever variable is referenced by$varName
. -
Return type declarations: Introduced in PHP 7, this feature allows functions to explicitly declare what types they return.
-
Exception Hierarchy introduced in PHP 7: PHP 7 brought a new exception hierarchy based on SPL (Standard PHP Library) with interfaces
Throwable
,Iterator
, and more, which improves the consistency and usability of exceptions. -
Spaceship Operator (
<=>
): Introduced in PHP 7, this operator compares two values and returns -1, 0, or 1 if the left operand is respectively less than, equal to, or greater than the right operand. -
Null Coalesce Operator (
??
): Also introduced in PHP 7, it provides a shorter syntax for theisset()
orempty()
and fallback pattern commonly used in PHP. -
CURL: A library built to support a range of common Internet software tasks, such as data transfer between an HTTP user agent and various servers.
-
PDO (PHP Data Objects): PDO is a database access layer providing a uniform method of accessing multiple databases. It allows you to use one set of functions for all supported databases and can help prevent SQL injection attacks.
-
Xdebug extension: A PHP extension that provides advanced debugging features, including performance profiling, code coverage analysis, and interactive debugging.
-
PHP.ini file: The main configuration file for the PHP language, which controls the behavior of the server at runtime. It contains directives to set various options that control everything from memory limits to whether or not you can execute PHP files.
-
New features in PHP 7: Other notable additions include return type declarations, scalar type declarations for function arguments, and many performance improvements. Additionally, PHP 7 introduced the removal of the
magic_quotes
andsafe_mode
parameters, as they are no longer necessary due to improvements in the language's design and library functions.
Remember, this is a high-level overview of the concepts, and each topic can be explored in much greater depth. Happy learning!
Loading charts...