Interview questions

Estimated reading time: 2 minutes

Interview questions

what are php errors? * notice * warning * parse/fatal error
How to show all errors and warning? * inside `php.ini` ```php error_reporting(E_ALL); ini_set('display_errors', 1); ```

</details>

what the different between == vs === ? * `==` is equal . it convert same type data before comparison. ```php '121' == 121 # true '0121' = 121 # false ``` * `===` identity. this don't convert same data type ```php '121' == 121 # false ```
what is constant variable? * constant variable can't mutation or change value. * `define` * `constant` keyword for constant variable. ```php define('version','1.0.1'); # outside of the class constant VERSION = '1.0.1'; # inside class ```
what is static variable? * static variable call first time then next time return modified value.
what is static function? * can access function without create class object. * access with scope method `::`
what is function? * function or method is a way for perform specific task ```php function name($param) { return "something"; } # access name('php interview'); ```
why use reference variable as parameter? * `&$refVar` * you can access variable outside of the block and that is modified value. ```php function name(&$param) { return $param; } # access name('php interview'); echo $param; # php interview ```
What is class? * Class is a blueprint. It contains properties and methods. * Class name's 1st letter will be Uppercase. * Class access by creating class object with `new` keyword
What is final class or final method? * `final` `class` can't able to inheritence/extends. * `final` `method` can't override.
php function's visibility (public,private,protected) ```bash ————————————————+———————————————+———————————+———————————————+————————————————— + This class | subclass | package | extends class ————————————————+———————————————+———————————+———————————————+————————————————— public | ✔ | ✔ | ✔ | ✔ ————————————————+———————————————+———————————+———————————————+————————————————— protected | ✔ | ✔ | ✔ | ✘ ————————————————+———————————————+———————————+———————————————+————————————————— private | ✔ | ✘ | ✘ | ✘ ————————————————+———————————————+———————————+———————————————+————————————————— ```
how to extend execution time? * `php.ini` ```php set_time_limit(int seconds); ```
what is the difference between include vs require? * include add a file . if file isn't exist that time return only a warning. * require works as like include . if isn't exist file that time return fatal error.
what is the difference between GET and POST? * Get displays all query as url . size max 2048 * retrive data * POST can't display query as url and no limit for query * insert * update
what is the difference between SESSION and COOKIE? * Get displays all query as url . size max 2048 * retrive data * POST can't display query as url and no limit for query * insert * update