{"id":21409558,"url":"https://github.com/mahmoudsayed96/interview-questions","last_synced_at":"2026-03-19T20:15:38.503Z","repository":{"id":124431482,"uuid":"415309737","full_name":"MahmoudSayed96/interview-questions","owner":"MahmoudSayed96","description":"List of questions that i asked in interviews","archived":false,"fork":false,"pushed_at":"2022-06-02T20:44:39.000Z","size":11523,"stargazers_count":0,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-01-23T04:29:12.397Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":null,"has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/MahmoudSayed96.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-10-09T12:58:39.000Z","updated_at":"2022-08-13T12:10:28.000Z","dependencies_parsed_at":null,"dependency_job_id":"93a00154-4616-4a5f-87eb-58e167d5921b","html_url":"https://github.com/MahmoudSayed96/interview-questions","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MahmoudSayed96%2Finterview-questions","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MahmoudSayed96%2Finterview-questions/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MahmoudSayed96%2Finterview-questions/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MahmoudSayed96%2Finterview-questions/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/MahmoudSayed96","download_url":"https://codeload.github.com/MahmoudSayed96/interview-questions/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243910382,"owners_count":20367537,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-22T17:27:06.305Z","updated_at":"2026-02-13T00:47:27.929Z","avatar_url":"https://github.com/MahmoudSayed96.png","language":null,"funding_links":[],"categories":[],"sub_categories":[],"readme":"# interview-questions\nList of questions that i asked in interviews\n\n1 - What is Dependancy Injection?\n\u003e Object dependant on another Object in example `Post` class depend on `User` class\n```php\nclass User {\n  public $username;\n  public $userAge;\n  \n  public function __constructor() {\n  \n  }\n}\n\nclass Post {\n  public $postTitle;\n  public $postBody;\n  public $user;\n  public function __constructor() {\n    // ...\n  }\n  \n  public function setUser(User $user) {\n    $this-\u003euser = $user;\n  }\n}\n```\nWhy don't use class in constructor?\n\u003e Becouse with each `Post` object created we need to pass user object to constructor.\n\n2 - Why using `localStorage` in javascript to store data and not using `Cookies` ?\n\u003e Becouse cookies send to server with each request but localStorage don't do this\n\n3 - What is diff between `Cookies` and `Sessions` and worked in server or client?\n\u003e The main difference between a session and a cookie is that `session` data is stored on the server, \n\u003e whereas `cookies` store data in the visitor’s browser.\n\n\u003e Sessions are more secure than cookies as it is stored in server. Cookie can be turned off from browser.\n\n\u003e Data stored in `cookie` can be stored for months or years, depending on the life span of the cookie. \n\u003e But the data in the `session` is lost when the web browser is closed.\n\n4 - What is `final class` and why use it ?\n \u003e The `final` keyword is used to prevent a class from being inherited and to prevent inherited method from being overridden.\n5 - What is diff between `abstract` ,`final` and `interface` class ?\n- Abstract class vs Interface.\n  \u003e Interface using for make blueprint structure.\n  \u003e \n  \u003e Abstract cannot be instantiated.\n1. **Methods Type**\n  \u003e `interface`: Contains only declered functions and public access.\n  \u003e \n  \u003e `abstract`: Contains declered and implemetaion functions.\n  ```php\n  interface A\n{\n    public function foo();\n}\n\nabstract class B {\n    public function foo(): string\n    {\n        return 'foo';\n    }\n\n    public abstract function buz();\n}\n  ```\n2. **Inheritance**\n  \u003e `interface`: Multiple inheritance.\n  \u003e \n  \u003e `abstract`: Single inheritance.\n  ```php\n  interface A {}\n  interface B {}\n  interface C {}\n  interface D extends A, B, C {}\n\n  abstract class A{}\n  abstract class B extends A{}\n  ```\n 3. Properties\n   \u003e `interface`: No properties.\n   \u003e \n   \u003e `abstract`: Has properties.\n4. Access Modiferies\n   \u003e `interface`: Public only.\n   \u003e \n   \u003e `abstract`: Any.\n**Final Class**.\n\u003e Final Class: A class which is declared with the `Final` keyword is known as the final class. \n\u003e The final keyword is used to finalize the implementations of the classes, the methods and the variables used in this class.\n\u003e \n\u003e *The main purpose of using a final class is to prevent the class from being inherited*.\n\n6. How laravel/JWT sotre use token in server?\n  \u003e the Laravel JWT Auth package, that the token is still being stored on the *server (using Laravel's cache system)* by default\n7. Reflaction Class in PHP.\n8. Eger loading VS. Lazy loading in laravel.\n9. Laravel Request LifeCycle.\n  ![Request Cycle](laravel-request-lifecycle.jfif)\n10. Laravel Service Provider\n   [Laravel Service Provider](https://www.youtube.com/watch?v=VYPfncvYW-Y\u0026t=208s)\n   [Arabic](https://5dmat-web.com/ar/playlist/31/%D8%AF%D8%B1%D9%88%D8%B3_%D9%85%D8%AA%D9%82%D8%AF%D9%85%D8%A9_%D9%81%D9%8A_laravel)\n11. Laravel Service Container\n   \u003e Manage classes dependancies\n    [Arabic](https://www.youtube.com/watch?v=Tnko0sRKQUU)\n12. What is Abstraction Concepts?\n  \u003e Abstraction is the concept of object-oriented programming that \"shows\" only essential attributes and \"hides\" unnecessary information. \n  \u003e The main purpose of abstraction is hiding the unnecessary details from the users.\n13. What is Closure Function and pass by value or refrence?.\n  ```php\n    $products = Product::with(['category' =\u003e function ($q) use ($request) {\n              // This is closure function.\n              // pass by value to pass by ref using '\u0026$request'\n              return $q-\u003ewhere('status', 1);\n     }]);\n  ```\n 14. What is diff `truncate` , `delete` and `drop` in database?.\n  **TRUNCATE**.\n  \u003e TRUNCATE Command is a Data Definition Language operation. It is used to remove all the records from a table. \n  \u003e It deletes all the records from an existing table but not the table itself. The structure or schema of the table is preserved.\n  \u003e\n  \u003e Truncate command marks the table for deallocation. This operation removes all the data from a table bypassing a number of constraints \n  \u003e enforced on the table. *MySQL does not allow the users to truncate the table which is referenced as FOREIGN KEY in another table*.\n\n **DELETE**.\n  \u003e The DELETE statement in SQL is a Data Manipulation Language(DML) Command. It is used to delete existing records from an existing table.\n  \u003e  We can delete a single record or multiple records depending on the condition specified in the query.\n  \u003e\n  \u003e The conditions are specified in the WHERE clause of the DELETE statement. If we omit the WHERE clause then all of the records \n  \u003e will be deleted and the table will be empty.\n  \u003e The DELETE statement scans every row before deleting it. Thus it is slower as compared to TRUNCATE command. If we want to delete all the records of a table,\n  \u003e it is preferable to use TRUNCATE in place of DELETE as the former is faster than the latter.\n\n**DROP**.\n \u003e DROP statement is a Data Definition Language(DDL) Command which is used to delete existing database objects. \n \u003e It can be used to delete databases, tables, views, triggers, etc.\n \u003e A DROP statement in SQL removes a component from a relational database management system (RDBMS).\n\n15. What is `csrf` in laravel ?.\n  \u003e This CSRF token is generated automatically for each user. This token is nothing but a random string that \n  \u003e is managed by the Laravel application to verify the user requests.\n  \u003e\n  \u003e How to Use: This CSRF token protection can be applied to any HTML form in Laravel application by \n  \u003e specifying a hidden form field of CSRF token. The requests are validated automatically by the CSRF VerifyCsrfToken middleware.\n  \u003e There are three different ways in which you can do this.\n  \u003e @csrf\n  \u003e csrf_field(): This function generate hidden html element.\n  \u003e csrf_token(): This function just gives a random string.\n\n16. What the poroblem `CROS` and why happend?\n17. What is OOP in PHP?\n *OOP stands for Object-Oriented Programming*.\n \u003e Procedural programming is about writing procedures or functions that perform operations on the data, while object-oriented programming \n \u003e is about creating objects that contain both data and functions.\n \u003e \n \u003e Object-oriented programming has several advantages over procedural programming:\n \u003e OOP is faster and easier to execute\n \u003e OOP provides a clear structure for the programs\n \u003e OOP helps to keep the PHP code DRY \"Don't Repeat Yourself\", and makes the code easier to maintain, modify and debug\n \u003e OOP makes it possible to create full reusable applications with less code and shorter development time.\n \n18. **SOLID**\n - **S**ingle Respons\n - [**O**pen/Close](/open-closed-principle-php-arabic.pdf)\n - [**L**iskov](liskov-substitution-principle-php-arabic.pdf)\n - [**I**nterface Segregation](Interface-segregation-principle-arabic.pdf)\n - [**D**ependency Inversion](dependency-inversion-principle-php-arabic.pdf)\n \n 19. What is **MVC** ?\n \u003e Design pattern using to structure code design for easier maintain and add features.\n \n 20. What is **ORM** ?\n \u003e ORM: Object Relational Mapping - Map Relational Records Into Object.\n\n21. [Service Provider](https://www.youtube.com/watch?v=Lf6R5oDtkFo\u0026list=PLSfH3ojgWsQosqpQUc28yP9jJZXrEylJY\u0026index=4)\n![Service Provider](laravel-serverc-provider.png)\n\n22. [**Faced** in laravel](https://www.youtube.com/watch?v=Ze9rS88iy0M\u0026list=PLSfH3ojgWsQosqpQUc28yP9jJZXrEylJY\u0026index=5)\n\u003e Faced allows us to call service instace method staticlly\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmahmoudsayed96%2Finterview-questions","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmahmoudsayed96%2Finterview-questions","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmahmoudsayed96%2Finterview-questions/lists"}