Passing by Reference
https://www.php.net/manual/en/language.references.pass.php
2.What is MVC?
MVC is a design pattern used to decouple user-interface (view), data (model), and application logic (controller). This pattern helps to achieve separation of concerns.
https://dotnet.microsoft.com/apps/aspnet/mvc
3.What is the difference between $_GET and $_POST?
$_GET — HTTP GET variables
$_POST — HTTP POST variables
https://www.php.net/manual/en/reserved.variables.php
4.What will be the output of each statements below and why?
5.After the code below is exexuted, what will be the value of $text and what will be strlen($text) return? Explain your answer.
$text = ‘John ‘;
$text[10] = ‘Doe’;
$text = 'John D';
strlen($text) = 11;
Javascript
1.What is the potential pitfall with using typeof bar == “object” to determine if bar is an object? How can this pitfall be avoided?
typeof null == "object"
bar != null && typeof bar == "object"
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/typeof
2.What is NaN? What is its type? How can you reliably test if a value is equal to NaN?
Not a number
Number
isNaN()
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/NaN
3.What is the difference between jQuery.get() and jQuery.ajax()?
$.get(url, data, success, dataType) is a shorthand Ajax function, which is equivalent to:
$.ajax({
url: url,
data: data,
success: success,
dataType: dataType
});
https://api.jquery.com/jQuery.get/
4.Write a simple function(less than 80 characters) returns a boolean indicating whether or not a string is palindrome.
A palindrome is a word, phrase, number, or other sequence of characters which reads the same backward or forward. Allowances may be made for adjustments to capital letters, punctuation, and word dividers.
console.log(isPalindrome("level")); // logs 'true'
console.log(isPalindrome("levels")); // logs 'false'
console.log(isPalindrome("A car, a man, a maraca")); // logs 'true'
function isPalindrome(str) {
str = str.replace(/\W/g, "").toLowerCase();
return str.split("").reverse().join("") == str;
}
With the best of your knowledge, create 2 Apis as following:
1 - Endpoint: /mail/contact
Description: This endpoint is used to send contact form to a specific email, It needs to use the SMTP server provided to dispatch the email to the target user, the email must include Name, Email, Message, and optionally an Attachment
Required Payload:
{
name: String,
email: String,
message: String,
attachment: File
}
Tasks
- [ ] Send email using sendgrid to a configurable user email
- [ ] Handle errors
- [ ] Send attachments
- [ ] Send formatted html emails (can be vary basic using tags like div, b, pre etc)
2 - Endpoint: /mail/subscription
Description: This endpoint is used to store user subscription emails, the goal is to keep every email stored in a persistent storage, where it can be later retrieve for further usage.
Required Payload: { email: string }
Tasks:
- [ ] Handles the case of duplicated entries
- [ ] Persist on local database
Additional Requirements:
The apis has to work asynchronously (Non Blocking), follow RESTful conventions, clean code, follow Laravel standards, and lastly don’t use excuses like: “I didn’t do this because it’s was a simple project i didn’t felt it was necessary” we want see what you are capable of so do everything that’s under your knowledge.
Deliverable:
- A ZIP of the project (without the vendor folder)
What‘s the difference between left join and right join?
Can you explain what‘s Eager Loading?
https://laravel.com/docs/6.x/eloquent-relationships#eager-loading
//If we have 25 books, this loop would run 26 queries
$books = App\Book::all();
foreach ($books as $book) {
echo $book->author->name;
}
//For this operation, only two queries will be executed
$books = App\Book::with('author')->get();
foreach ($books as $book) {
echo $book->author->name;
}
/**
* https://www.php.net/manual/en/intro.spl.php
**/
The Standard PHP Library (SPL) is a collection of interfaces and classes that are meant to solve common problems.
No external libraries are needed to build this extension and it is available and compiled by default in PHP 5.0.0.
SPL provides a set of standard datastructure, a set of iterators to traverse over objects, a set of interfaces, a set of standard Exceptions, a number of classes to work with files and it provides a set of functions like spl_autoload_register()
/**
* https://www.php.net/manual/zh/class.iterator.php
**/
/**
* https://www.php.net/manual/zh/language.generators.overview.php
**/
Most MySQL indexes (PRIMARY KEY, UNIQUE, INDEX, and FULLTEXT) are stored in B-trees. Exceptions: Indexes on spatial data types use R-trees; MEMORY tables also support hash indexes; InnoDB uses inverted lists for FULLTEXT indexes.
final class Singleton
{
/**
* @var Singleton
*/
private static $instance;
/**
* gets the instance via lazy initialization (created on first usage)
*/
public static function getInstance(): Singleton
{
if (null === static::$instance) {
static::$instance = new static();
}
return static::$instance;
}
/**
* is not allowed to call from outside to prevent from creating multiple instances,
* to use the singleton, you have to obtain the instance from Singleton::getInstance() instead
*/
private function __construct()
{
}
/**
* prevent the instance from being cloned (which would create a second instance of it)
*/
private function __clone()
{
}
/**
* prevent from being unserialized (which would create a second instance of it)
*/
private function __wakeup()
{
}
}
https://github.com/domnikl/DesignPatternsPHP/blob/master/Creational/Singleton/Singleton.php
https://phptherightway.com/pages/Design-Patterns.html
https://stackoverflow.com/questions/203336/creating-the-singleton-design-pattern-in-php5