{"id":23932384,"url":"https://github.com/makstyle119/php","last_synced_at":"2026-04-11T21:12:53.698Z","repository":{"id":134501118,"uuid":"597757007","full_name":"makstyle119/php","owner":"makstyle119","description":"PHP from beginner to advanced ","archived":false,"fork":false,"pushed_at":"2025-01-05T16:32:31.000Z","size":168,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-02-07T16:43:34.602Z","etag":null,"topics":["begginer-friendly","makstyle119","php","tutorial"],"latest_commit_sha":null,"homepage":"","language":"PHP","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/makstyle119.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":"2023-02-05T14:54:53.000Z","updated_at":"2025-01-13T08:44:56.000Z","dependencies_parsed_at":"2025-01-05T17:37:45.067Z","dependency_job_id":null,"html_url":"https://github.com/makstyle119/php","commit_stats":null,"previous_names":["makstyle119/php","makstyle119/phpcrashcourse"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/makstyle119%2Fphp","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/makstyle119%2Fphp/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/makstyle119%2Fphp/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/makstyle119%2Fphp/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/makstyle119","download_url":"https://codeload.github.com/makstyle119/php/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":240404867,"owners_count":19796080,"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":["begginer-friendly","makstyle119","php","tutorial"],"created_at":"2025-01-06T00:19:25.458Z","updated_at":"2025-10-25T14:43:43.900Z","avatar_url":"https://github.com/makstyle119.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# PHP\n\nthis is my journey to learn and understand PHP\n\n## Folder Structure:\n\n```\n├── 📂 php-revision\n    ├── 📂 src\n      |- 001_output.php\n      |- 002_variables.php\n      |- 003_arrays.php\n      |- 004_conditionals.php\n      |- 005_loops.php\n      |- 006_functions.php\n      |- 007_array_functions.php\n      |- 008_string_functions.php\n      |- 009_super_globals.php\n      |- 010_get_post.php\n      |- 011_sanitizing_inputs.php\n      |- 012_cookies.php\n      |- 013_sessions.php\n      |- 014_file_handling.php\n      |- 015_file_upload.php\n      |- 016_exception.php\n      |- 017_oop.php\ndocker-compose.yml\nDockerfile\nREADME.md\n```\n\n## Code Explaining\n\n- 000/folder-structure\n```\nNothing much just basic folder structure\n```\n\n- php-revision/src/001_output.php\n  - `echo` most common thing use for printing (specially for debugging) - with `echo` you can print multiple values using as comma separated values - only string and numbers\n  - `print` same as `echo` but only print single value\n  - `print_r()` use a lot with arrays\n  - `var_dump()` against use a lot with array but can use with anything - return type as well\n  - `var_export()` similar with `var_dump()` but not as efficient as `var_dump()` is\n  - `\u003c?= 'Some Text' ?\u003e` single line only - same as `echo`\n```\n\u003c?php // This is a php tag. If there is no html or other content below the php, we don't need to close the php tag.\n\n  // echo 'hello World';\n  // // Single line comments\n  // /**\n  //  * Multiline Comments\n  //  */\n  // // You need semicolon at the send of every statement ';'\n\n  /* ------- Outputting Content ------- */\n  \n  // // Echo - Output strings, numbers, html, etc\n  // echo 123, 'Hello', 10.5;\n\n  // // print - Similar to echo, but a bit slower\n  // print('Hello');\n\n  // // print_r - Gives a bit more info. Can be used to print arrays\n  // print_r('Hello');\n  // print_r([1, 2, 3]);\n\n  // // var_dump - Even more info like data type and length\n  // var_dump('Hello');\n  // var_dump([1, 2, 3]);\n\n  // // var_export - Similar to var_dump(). Output a string representation of a variable\n  // var_export('Hello');\n\n?\u003e\n\n\u003c!DOCTYPE html\u003e\n\u003chtml lang=\"en\"\u003e\n\u003chead\u003e\n  \u003cmeta charset=\"UTF-8\"\u003e\n  \u003cmeta http-equiv=\"X-UA-Compatible\" content=\"IE=edge\"\u003e\n  \u003cmeta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\"\u003e\n  \u003ctitle\u003e01_output\u003c/title\u003e\n\u003c/head\u003e\n\u003cbody\u003e\n  \u003ch1\u003e\n    \u003c?php echo 'Post One';?\u003e\n  \u003c/h1\u003e\n  \u003ch1\u003e\n    \u003c?='Post Two' ?\u003e\n  \u003c/h1\u003e\n\u003c/body\u003e\n\u003c/html\u003e\n\n```\n\n- php-revision/src/002_variables.php\n  - `Variables`\n    - `String` - A string is a series of characters surrounded by quotes\n    - `Integer` - Whole numbers\n    - `Float` - Decimal numbers\n    - `Boolean` - true or false\n    - `Array` - An array is a special variable, which can hold more than one value\n    - `Object` - A class\n    - `NULL` - Empty variable\n    - `Resource` - A special variable that holds a resource\n  - `Data Types`\n    - `Variables` must be prefixed with $\n    - `Variables` must start with a letter or the underscore character\n    - `variables` can't start with a number\n    - `Variables` can only contain alpha-numeric characters and underscores (A-z, 0-9, and _ )\n    - `Variables` are case-sensitive ($name and $NAME are two different variables)\n```\n\u003c?php\n\n/* ----- Variables \u0026 Data Types ----- */\n\n/* --------- PHP Data Types --------- */\n/*\n- String - A string is a series of characters surrounded by quotes\n- Integer - Whole numbers\n- Float - Decimal numbers\n- Boolean - true or false\n- Array - An array is a special variable, which can hold more than one value\n- Object - A class\n- NULL - Empty variable\n- Resource - A special variable that holds a resource\n*/\n\n/* --------- Variable Rules --------- */\n/*\n- Variables must be prefixed with $\n- Variables must start with a letter or the underscore character\n- variables can't start with a number\n- Variables can only contain alpha-numeric characters and underscores (A-z, 0-9, and _ )\n- Variables are case-sensitive ($name and $NAME are two different variables)\n*/\n\n$name = \"MAK\"; // string\n$age = 22; // int\n$has_kids = false; // boolean\n$has_on_hand = 100; // float\n\necho $name . \"\\t\";\necho $age . \"\\t\";\necho $has_kids . \"\\t\";\necho $has_on_hand . \"\\t\";\n\necho \"\u003cbr /\u003e\" . $name . ' is ' . $age . ' year old. and have ' . $has_on_hand . ' money'; // this is how you can do contact in php\necho \"\u003cbr /\u003e $name is $age year old. and have $has_on_hand money \u003cbr /\u003e\"; // this is another way\n\n$x = '5' + '5'; // php will still consider it as int;\nvar_dump($x);\n\necho \"\\t\" . 10 - 5 . \"\\t\";\necho 10 * 5 . \"\\t\";\necho 10 / 5 . \"\\t\";\necho 10 % 5 . \"\\t\";\n\necho \"\u003cbr /\u003e\";\n\n// constant\ndefine('HOST', 'localhost'); // never change\n\necho HOST;\n```\n\n- php-revision/src/003_arrays.php\n  - `Arrays`\n    - `Simple Array` - anything between two large brackets with a comma to separate them is a simple array.\n    - `Associate Array` - in associate array we will set key and value just like object in js.\n    - `Multi Dimension Array` - here we will have array inside another array\n```\n\u003c?php\n    // Simple Array\n    $numbers = [1, 2, 3, 4, 5];\n    $fruits = array('apple', 'orange', 'banana');\n\n    print_r($numbers);\n    var_dump($fruits);\n    echo $fruits[1];\n\n    // Associate Array\n    $color = [\n        'black' =\u003e '#000',\n        'white' =\u003e '#fff'\n    ];\n\n    echo $color['black'];\n\n    // Multi Dimension Array\n    $people = [\n        [\n            'first_name' =\u003e 'Moiz',\n            'last_name' =\u003e 'Ali',\n            'email' =\u003e 'some.email@cool.com'\n        ],\n        [\n            'first_name' =\u003e 'Maria',\n            'last_name' =\u003e 'Khan',\n            'email' =\u003e 'some.email2@cool.com'\n        ]\n    ];\n\n    echo $people[1]['email'];\n\n    // convert an array into json\n    var_dump(json_encode($people));\n```\n\n- php-revision/src/04_conditionals.php\n  - If else\n    - `if (condition)` - check if the statement is true\n    - `elseif (condition)` - same as if check for second or more condition - optional\n    - `else` - this will run if no condition match - optional\n  - Ternary operator\n    - `?` this is if statement\n    - `-` this is else\n    - `?` and `-` should run together\n    - `\u0026\u0026` this is and operator\n    - `??` this will check for first value and if not exist then go for second\n  - Switch cases\n    - `switch(condition)` - switch case are same as if else here you start with passing the parameter then check if on every case\n    - `case value` - check if provided value is same as parameter\n    - `break` - to break the switch case\n    - `default` - it will run if no other case match - optional\n```\n\u003c?php\n\n/* ---- Conditionals \u0026 Operators ---- */\n\n/* ------------ Operators ----------- */\n\n/*\n    \u003c Less than\n    \u003e Greater than\n    \u003c= Less than or equal to\n    \u003e= Greater than or equal to\n    == Equal to\n    === Identical to\n    != Not equal to\n    !== Not identical to\n*/\n\n/* ---------- If \u0026 If-Else Statements --------- */\n\n/*\n** If Statement Syntax\nif (condition) {\n  // code to be executed if condition is true\n} \n*/\n\n$age = 20;\n\nif ($age \u003e 18) \n{\n    echo 'you are old enough' + \"\\n\";\n} \nelseif ($age \u003c 100) // elseif is adding a second or more conditions\n{\n    echo 'too much old' + \"\\n\";\n} \nelse // else is a default which will run if no condition match\n{\n    echo 'you are not old enough' + \"\\n\";\n}\n\n$sports = ['Cricket'];\n\nif (empty($sports)) // empty is a built in function to check is array is empty or not \n{\n    echo 'no sports exist' + \"\\n\";\n}\n\n/* -------- Ternary Operator -------- */\n/*\n    The ternary operator is a shorthand if statement.\n    Ternary Syntax:\n        condition ? true : false;\n*/\n\necho empty($sports) ? 'no sports exist' :  $sports[0] + \"\\n\";\n\necho empty($sports) \u0026\u0026 'no sports exist' + \"\\n\";\n\n$first_post = $sports[0] ?? null; //  ?? will check for first value if not exist add second value\n\n/* -------- Switch Statements ------- */\n\n$fav_color = 'red';\n\nswitch($fav_color) // switch case are same as if else here you start with passing the parameter then check if on every case\n{\n    case 'red': // check if provided value is same as parameter\n        echo 'Your Favorite color is red';\n        break; // to break the switch case\n    case 'blue':\n        echo 'Your Favorite color is blue';\n        break;\n    default: // it will run if no other case match\n        echo 'I don\\'t recognized your favorite color';\n        break;\n}\n\n?\u003e\n```\n\n- php-revision/src/005_loop.php\n  - `for loop`\n    - `for($a = 0; $a \u003c= 10; $a++)` - for loop have 3 parts - 1. initialize the variable - 2. add the condition (how much you want to run this loop) - 3. increment or decrement the value\n  - `while Loop`\n    - `while ($b \u003c= 0)` - same as for loop you put your condition and it will run until condition become true\n    - `$b -= 1;` - here we will pu increment or decrement\n  - `do while loop`\n    - `do {}` - in do while loop we perform the task first then check condition - in other words if you want to run condition at least one time use this\n    - `$c++;` - increment or decrement\n    - `while ($c \u003c 0);` - checking the condition here\n  - `foreach loop`\n    - `foreach ($posts as $index =\u003e $post)` - we use this for array - you can use above loops for arrays as well it just it more common to use - we can get index and individual value from the array using foreach\n```\n\u003c?php\n\n/* -------- Loops \u0026 Iteration ------- */\n\n/* ------------ For Loop ------------ */\n\n/*\n** For Loop Syntax\n    for (initialize; condition; increment) {\n        // code to be executed\n    }\n*/\n\necho \"for loop start here\" . \"\u003cbr /\u003e\" . \"\u003cbr /\u003e\";\n\nfor($a = 0; $a \u003c= 10; $a++) // for loop have 3 parts - 1) initialize the variable - 2) add the condition (how much you want to run this loop) - 3) increment or decrement the value\n{\n    echo $a . \"\u003cbr /\u003e\"; // do whatever you like here\n}\n\necho  \"\u003cbr /\u003e\" . \"for loop ends here\" . \"\u003cbr /\u003e\";\n\n/* ------------ While Loop ------------ */\n\n/*\n** While Loop Syntax\n    while (condition) {\n        // code to be executed\n    }\n*/\n\necho \"\u003cbr /\u003e\" . \"while loop start here\" . \"\u003cbr /\u003e\" . \"\u003cbr /\u003e\";\n\n$b = 15;\nwhile ($b \u003c= 0) // same as for loop you put your condition and it will run until condition become true\n{\n    echo $b . \"\u003cbr /\u003e\";\n    $b -= 1; // here we will pu increment or decrement\n}\n\necho \"\u003cbr /\u003e\" . \"while loop ends here\" . \"\u003cbr /\u003e\";\n\n/* ---------- Do While Loop --------- */\n\n/*\n** Do While Loop Syntax\n    do {\n        // code to be executed\n    } while (condition);\n\ndo...while loop will always execute the block of code once, even if the condition is false.\n*/\n\necho \"\u003cbr /\u003e\" . \"do while loop start here\" . \"\u003cbr /\u003e\" . \"\u003cbr /\u003e\";\n\n$c = 0;\n\ndo { // in do while loop we perform the task first then check condition - in other words if you want to run condition at least one time use this\n    echo $c . \"\u003cbr /\u003e\";\n    $c++; // increment or decrement\n} while ($c \u003c 0); // checking the condition here\n\necho \"\u003cbr /\u003e\" . \"do while loop ends here\" . \"\u003cbr /\u003e\";\n\n/* ---------- Foreach Loop ---------- */\n\n/*\n** Foreach Loop Syntax\n    foreach ($array as $value) {\n        // code to be executed\n    }\n*/\n\necho \"\u003cbr /\u003e\" . \"foreach loop start here\" . \"\u003cbr /\u003e\" . \"\u003cbr /\u003e\";\n\n$posts = ['first post', 'second post', 'third post'];\n\nforeach ($posts as $index =\u003e $post) // we use this for array - you can use above loops for arrays as well it just it more common to use - we can get index and individual value from the array using foreach\n{\n    echo \"(\" . $index . \")\" . \" \" .$post . \"\u003cbr\u003e\";\n}\n\necho \"\u003cbr /\u003e\" . \"foreach loop ends here\" . \"\u003cbr /\u003e\";\n\n?\u003e\n```\n\n- php-revision/src/006_functions.php\n  - `function` - Functions are reusable blocks of code that we can call to perform a specific task. We can pass values into functions to change their behavior. Functions have their own local scope as opposed to global scope\n    - `normal function` \n      - `function register_user($email)` - to create a function you need to use function key word and then function name and the open brackets - you can use argument in the function - argument can be use to get user input or value which can help function functionality\n      - `echo $name . ' registered with ' . $email;` // function have strict scope you can't use anything outside or don't use any variable which you declare inside the function outside\n      - `global $name;` // using global keyword we can add global scope variable into local scope\n      - `register_user('makstyle119@gmail.com');` // function doesn't run by their own you have to run the manually by calling their name\n      - `$sum_value = sum(2, 3);` // function can run by them self or can be assign to a variable\n    - `anonymous function`\n      - `$subtraction = function($a, $b) {` // when you assign function directly to a variable like this - this is called anonymous function\n    - `arrow function`\n      - `$multiplication = fn($a, $b) =\u003e $a * $b;` // this is how you can create a arrow function use fn to create a function and if it's a single line function you don't need return or brackets\n```\n\u003c?php\n/* ------------ Functions ----------- */\n\n/*\n    Functions are reusable blocks of code that we can call to perform a specific task.\n    We can pass values into functions to change their behavior. Functions have their own local scope as opposed to global scope\n\n\n/*\n** Function Syntax\n    function functionName($arg1, $arg2, ...) {\n        // code to be executed\n    }\n*/\n\necho \"normal function start here\" . \"\u003cbr /\u003e\" . \"\u003cbr /\u003e\";\n\n$name = 'MAK';\n\nfunction register_user($email) // to create a function you need to use function key word and then function name and the open brackets - you can use argument in the function - argument can be use to get user input or value which can help function functionality \n{\n    global $name; // using global keyword we can add global scope variable into local scope\n    echo $name . ' registered with ' . $email . \"\u003cbr /\u003e\"; // function have strict scope you can't use anything outside or don't use any variable which you declare inside the function outside\n}\n\nregister_user('makstyle119@gmail.com'); // function doesn't run by their own you have to run the manually by calling their name\n\nfunction sum($a, $b = 4) {\n    return $a + $b; // function can return and can be void - your argument can have a default value so you if you don't pass the parameter while calling the function default value will be use\n}\n\n$sum_value = sum(2, 3); // function can run by them self or can be assign to a variable\n\necho $sum_value . \"\u003cbr /\u003e\";\n\necho \"\u003cbr /\u003e\" . \"normal function ends here\" . \"\u003cbr /\u003e\";\n\necho \"\u003cbr /\u003e\" . \"anonymous function start here\" . \"\u003cbr /\u003e\";\n\n$subtraction = function($a, $b) // when you assign function directly to a variable like this - this is called anonymous function\n{  \n    return $a - $b;\n};\n\necho $subtraction(3, 1) . \"\u003cbr /\u003e\";\n\necho \"\u003cbr /\u003e\" . \"anonymous function ends here\" . \"\u003cbr /\u003e\";\n\necho \"\u003cbr /\u003e\" . \"arrow function start here\" . \"\u003cbr /\u003e\";\n\n$multiplication = fn($a, $b) =\u003e $a * $b . \"\u003cbr /\u003e\"; // this is how you can create a arrow function use fn to create a function and if it's a single line function you don't need return or brackets\n\necho $multiplication(3, 4) . \"\u003cbr /\u003e\";\n\necho \"\u003cbr /\u003e\" . \"arrow function ends here\" . \"\u003cbr /\u003e\";\n\n?\u003e\n\n```\n\n- php-revision/src/007_array_functions.php\n  - `count($fruits);` // count array length\n  - `var_dump(in_array('apple', $fruits));` // search in array\n  - `$fruits[] = 'grape';` // add in the last\n  - `array_push($fruits, 'blueberry', 'strawberry');` // add in the last\n  - `array_unshift($fruits, 'mango');` // add in the first\n  - `array_pop($fruits);` // remove last\n  - `array_shift($fruits);` // remove first\n  - `unset($fruits[2]);` // remove by index and also the index\n  - `$chunked_array` = array_chunk($fruits, 2); // second argument is the n\n  - `$arr3 = array_merge($arr1, $arr2);` // merge two arrays\n  - `$arr4 = [...$arr1, ...$arr2];` // merge two arrays\n  - `$combineColorAndFruitArray = array_combine($color, $fruit);` // combine two arrays\n  - `$keys = array_keys($combineColorAndFruitArray);` // return keys of an array\n  - `$flipped = array_flip($combineColorAndFruitArray);` // flip the array\n  - `$numbersTillTwenty = range(0, 20);` // make range in form of array\n  - `$numbersTillTwentyWithString = array_map(function($number) {`\n    `return \"Number $number\";`\n  `}, $numbersTillTwenty);` // run a map in the array\n  - `$lessThenTen = array_filter($numbersTillTwenty, fn($number) =\u003e $number \u003c 10);` // run a map and return where condition match \n  - `$sum = array_reduce($numbersTillTwenty, fn($carry, $number) =\u003e $carry + $number);` // run a reducer in a array\n```\n\u003c?php\n/* --------- Array Functions -------- */\n\n/*\n    Functions to work with arrays\n    https://www.php.net/manual/en/ref.array.php\n*/\n\n// array\n$fruits = ['apple', 'orange', 'pear'];\n\necho \"================================================== count start ==================================================\" . \"\u003cbr /\u003e\" . \"\u003cbr /\u003e\";\n\necho count($fruits); // count array length\n\necho \"\u003cbr /\u003e\" . \"\u003cbr /\u003e\" . \"================================================== count end ==================================================\";\necho \"\u003cbr /\u003e\" . \"\u003cbr /\u003e\" . \"================================================== search start ==================================================\" . \"\u003cbr /\u003e\" . \"\u003cbr /\u003e\";\n\nvar_dump(in_array('apple', $fruits)); // search in array\n\necho \"\u003cbr /\u003e\" . \"\u003cbr /\u003e\" . \"================================================== search end ==================================================\";\necho \"\u003cbr /\u003e\" . \"\u003cbr /\u003e\" . \"================================================== add in the array  start ==================================================\" . \"\u003cbr /\u003e\" . \"\u003cbr /\u003e\";\n\n$fruits[] = 'grape'; // add in the last\n\nprint_r($fruits);\n\necho \"\u003cbr /\u003e\" . \"\u003cbr /\u003e\" . \"================================================== add in the array end ==================================================\";\necho \"\u003cbr /\u003e\" . \"\u003cbr /\u003e\" . \"================================================== array_push start ==================================================\" . \"\u003cbr /\u003e\" . \"\u003cbr /\u003e\";\n\narray_push($fruits, 'blueberry', 'strawberry'); // add in the last\n\nprint_r($fruits);\n\necho \"\u003cbr /\u003e\" . \"\u003cbr /\u003e\" . \"================================================== array_push end ==================================================\";\necho \"\u003cbr /\u003e\" . \"\u003cbr /\u003e\" . \"================================================== array_unshift start ==================================================\" . \"\u003cbr /\u003e\" . \"\u003cbr /\u003e\";\n\narray_unshift($fruits, 'mango'); // add in the first\n\nprint_r($fruits);\n\necho \"\u003cbr /\u003e\" . \"\u003cbr /\u003e\" . \"================================================== array_unshift end ==================================================\";\necho \"\u003cbr /\u003e\" . \"\u003cbr /\u003e\" . \"================================================== array_pop start ==================================================\" . \"\u003cbr /\u003e\" . \"\u003cbr /\u003e\";\n\narray_pop($fruits); // remove last\n\nprint_r($fruits);\n\necho \"\u003cbr /\u003e\" . \"\u003cbr /\u003e\" . \"================================================== array_pop end ==================================================\";\necho \"\u003cbr /\u003e\" . \"\u003cbr /\u003e\" . \"================================================== array_shift start ==================================================\" . \"\u003cbr /\u003e\" . \"\u003cbr /\u003e\";\n\narray_shift($fruits); // remove first\n\nprint_r($fruits);\n\necho \"\u003cbr /\u003e\" . \"\u003cbr /\u003e\" . \"================================================== array_shift end ==================================================\";\necho \"\u003cbr /\u003e\" . \"\u003cbr /\u003e\" . \"================================================== unset start ==================================================\" . \"\u003cbr /\u003e\" . \"\u003cbr /\u003e\";\n\nunset($fruits[2]); // remove by index and also the index\n\nprint_r($fruits);\n\necho \"\u003cbr /\u003e\" . \"\u003cbr /\u003e\" . \"================================================== unset end ==================================================\";\necho \"\u003cbr /\u003e\" . \"\u003cbr /\u003e\" . \"================================================== split the array into n number - start ==================================================\" . \"\u003cbr /\u003e\" . \"\u003cbr /\u003e\";\n\n$chunked_array = array_chunk($fruits, 2); // second argument is the n\n\nprint_r($chunked_array);\n\necho \"\u003cbr /\u003e\" . \"\u003cbr /\u003e\" . \"================================================== split the array into n number - end ==================================================\";\necho \"\u003cbr /\u003e\" . \"\u003cbr /\u003e\" . \"================================================== array merge start ==================================================\" . \"\u003cbr /\u003e\" . \"\u003cbr /\u003e\";\n\n$arr1 = [1, 2, 3];\n$arr2 = [4, 5, 6];\n\n$arr3 = array_merge($arr1, $arr2); // merge two arrays\n\nprint_r($arr3);\n\necho \"\u003cbr /\u003e\" . \"\u003cbr /\u003e\" . \"================================================== array merge end ==================================================\";\necho \"\u003cbr /\u003e\" . \"\u003cbr /\u003e\" . \"================================================== split operator start ==================================================\" . \"\u003cbr /\u003e\" . \"\u003cbr /\u003e\";\n\n$arr1 = [1, 2, 3];\n$arr2 = [4, 5, 6];\n\n$arr4 = [...$arr1, ...$arr2]; // merge two arrays\n\nprint_r($arr4);\n\necho \"\u003cbr /\u003e\" . \"\u003cbr /\u003e\" . \"================================================== split operator end ==================================================\";\necho \"\u003cbr /\u003e\" . \"\u003cbr /\u003e\" . \"================================================== combine two array with key value pair - start ==================================================\" . \"\u003cbr /\u003e\" . \"\u003cbr /\u003e\";\n\n$color = ['green', 'red', 'yellow'];\n$fruit = ['avocado', 'apple', 'banana'];\n\n$combineColorAndFruitArray = array_combine($color, $fruit); // combine two arrays\n\nprint_r($combineColorAndFruitArray);\n\necho \"\u003cbr /\u003e\" . \"\u003cbr /\u003e\" . \"================================================== combine two array with key value pair - end ==================================================\";\necho \"\u003cbr /\u003e\" . \"\u003cbr /\u003e\" . \"================================================== get only keys of an array - start ==================================================\" . \"\u003cbr /\u003e\" . \"\u003cbr /\u003e\";\n\n$keys = array_keys($combineColorAndFruitArray); // return keys of an array\n\nprint_r($keys);\n\necho \"\u003cbr /\u003e\" . \"\u003cbr /\u003e\" . \"================================================== get only keys of an array - end ==================================================\";\necho \"\u003cbr /\u003e\" . \"\u003cbr /\u003e\" . \"================================================== flip the array - value become key and key become value - start ==================================================\" . \"\u003cbr /\u003e\" . \"\u003cbr /\u003e\";\n\n$flipped = array_flip($combineColorAndFruitArray); // flip the array\n\nprint_r($flipped);\n\necho \"\u003cbr /\u003e\" . \"\u003cbr /\u003e\" . \"================================================== flip the array - value become key and key become value - end ==================================================\";\necho \"\u003cbr /\u003e\" . \"\u003cbr /\u003e\" . \"================================================== create a range from n to m - start ==================================================\" . \"\u003cbr /\u003e\" . \"\u003cbr /\u003e\";\n\n$numbersTillTwenty = range(0, 20); // make range in form of array\n\nprint_r($numbersTillTwenty);\n\necho \"\u003cbr /\u003e\" . \"\u003cbr /\u003e\" . \"================================================== create a range from n to m - end ==================================================\";\necho \"\u003cbr /\u003e\" . \"\u003cbr /\u003e\" . \"================================================== create a range with adding more data in return - start ==================================================\" . \"\u003cbr /\u003e\" . \"\u003cbr /\u003e\";\n\n$numbersTillTwentyWithString = array_map(function($number) {\n    return \"Number $number\";\n}, $numbersTillTwenty); // run a map in the array\n\nprint_r($numbersTillTwentyWithString);\n\necho \"\u003cbr /\u003e\" . \"\u003cbr /\u003e\" . \"================================================== create a range with adding more data in return - end ==================================================\";\necho \"\u003cbr /\u003e\" . \"\u003cbr /\u003e\" . \"================================================== filter start ==================================================\" . \"\u003cbr /\u003e\" . \"\u003cbr /\u003e\";\n\n$lessThenTen = array_filter($numbersTillTwenty, fn($number) =\u003e $number \u003c 10); // run a map and return where condition match\n\nprint_r($lessThenTen);\n\necho \"\u003cbr /\u003e\" . \"\u003cbr /\u003e\" . \"================================================== filter end ==================================================\";\necho \"\u003cbr /\u003e\" . \"\u003cbr /\u003e\" . \"================================================== reduce start ==================================================\" . \"\u003cbr /\u003e\" . \"\u003cbr /\u003e\";\n\n$sum = array_reduce($numbersTillTwenty, fn($carry, $number) =\u003e $carry + $number); // run a reducer in a array\n\nvar_dump($sum);\n\necho \"\u003cbr /\u003e\" . \"\u003cbr /\u003e\" . \"================================================== reduce end ==================================================\";\n\n?\u003e\n\n```\n\n- php-revision/src/008_string_functions.php\n  - `strlen($string);` // Get the length of a string\n  - `strpos($string, 'o');` // Find the position of the first occurrence of a substring in a string\n  - `strrpos($string, 'o');` // Find the position of the last occurrence of a substring in a string\n  - `strrev($string);` // Reverse a string\n  - `strtolower($string);` // Convert all characters to lowercase\n  - `strtoupper($string);` // Convert all characters to uppercase\n  - `ucwords($string);` // Uppercase the first character of each word\n  - `str_replace('World', 'Everyone', $string);` // String replace\n  - `substr($string, 0, 5);` // Return portion of a string specified by the offset and length\n  - `substr($string, 5);` // Return portion of a string specified by the offset and length\n  - `str_starts_with($string, 'Hello')` // Starts with\n  - `str_ends_with($string, 'Hello')` // Starts with\n  - `htmlentities($string2);` // HTML Entities\n  - `printf('%s is a %s', 'Brad', 'nice guy');` // Formatted Strings - useful when you have outside data - Different specifiers for different data types\n```\n\u003c?php\n/* ---------- String Functions -------- */\n\n/*\n    Functions to work with strings\n    https://www.php.net/manual/en/ref.strings.php\n*/\n\n$string = 'Hello World';\n\n// Get the length of a string\necho strlen($string);\n\n// Find the position of the first occurrence of a substring in a string\necho strpos($string, 'o');\n\n// Find the position of the last occurrence of a substring in a string\necho strrpos($string, 'o');\n\n// Reverse a string\necho strrev($string);\n\n// Convert all characters to lowercase\necho strtolower($string);\n\n// Convert all characters to uppercase\necho strtoupper($string);\n\n// Uppercase the first character of each word\necho ucwords($string);\n\n// String replace\necho str_replace('World', 'Everyone', $string);\n\n// Return portion of a string specified by the offset and length\necho substr($string, 0, 5);\necho substr($string, 5);\n\n// Starts with\nif (str_starts_with($string, 'Hello')) {\n    echo 'YES';\n}\n\n// Ends with\nif (str_ends_with($string, 'ld')) {\n    echo 'YES';\n}\n\n// HTML Entities\n$string2 = '\u003ch1\u003eHello World\u003c/h1\u003e';\necho htmlentities($string2);\n\n// Formatted Strings - useful when you have outside data\n// Different specifiers for different data types\nprintf('%s is a %s', 'Brad', 'nice guy');\nprintf('1 + 1 = %f', 1 + 1); // float\n\n?\u003e\n```\n\n- php-revision/src/009_super_globals.php\n  - `$GLOBALS` // A superglobal variable that holds information about any variables in global scope.\n  - `$_GET` // Contains information about variables passed through a URL or a form.\n  - `$_POST` //  Contains information about variables passed through a form.\n  - `$_COOKIE` // Contains information about variables passed through a cookie.\n  - `$_SESSION` // Contains information about variables passed through a session.\n  - `$_SERVER` // Contains information about the server environment.\n  - `$_ENV` // Contains information about the environment variables.\n  - `$_FILES` //  Contains information about files uploaded to the script.\n  - `$_REQUEST` // Contains information about variables passed through the form or URL.\n```\n\u003c?php\n/* ---------- Superglobals ---------- */\n//Built in variables that are always available in all scopes\n\n/*\n    $GLOBALS - A superglobal variable that holds information about any variables in global scope.\n    $_GET - Contains information about variables passed through a URL or a form.\n    $_POST -  Contains information about variables passed through a form.\n    $_COOKIE - Contains information about variables passed through a cookie.\n    $_SESSION - Contains information about variables passed through a session.\n    $_SERVER - Contains information about the server environment.\n    $_ENV - Contains information about the environment variables.\n    $_FILES -  Contains information about files uploaded to the script.\n    $_REQUEST - Contains information about variables passed through the form or URL.\n*/\n\n// var_dump($GLOBALS);\n// var_dump($_GET);\n// var_dump($_REQUEST);\n?\u003e\n\u003c!DOCTYPE html\u003e\n\u003chtml lang=\"en\"\u003e\n\n\u003chead\u003e\n    \u003cmeta charset=\"UTF-8\"\u003e\n    \u003cmeta http-equiv=\"X-UA-Compatible\" content=\"IE=edge\"\u003e\n    \u003cmeta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\"\u003e\n    \u003ctitle\u003eDocument\u003c/title\u003e\n\u003c/head\u003e\n\n\u003cbody\u003e\n    \u003cul\u003e\n        \u003cli\u003eHost: \u003c?php echo $_SERVER['HTTP_HOST']; ?\u003e\u003c/li\u003e\n        \u003cli\u003eDocument Root: \u003c?php echo $_SERVER['DOCUMENT_ROOT']; ?\u003e\u003c/li\u003e\n        \u003cli\u003eSystem Root: \u003c?php echo $_SERVER['SystemRoot']; ?\u003e\u003c/li\u003e\n        \u003cli\u003eServer Name: \u003c?php echo $_SERVER['SERVER_NAME']; ?\u003e\u003c/li\u003e\n        \u003cli\u003eServer Port: \u003c?php echo $_SERVER['SERVER_PORT']; ?\u003e\u003c/li\u003e\n        \u003cli\u003eCurrent File Dir: \u003c?php echo $_SERVER['PHP_SELF']; ?\u003e\u003c/li\u003e\n        \u003cli\u003eRequest URI: \u003c?php echo $_SERVER['REQUEST_URI']; ?\u003e\u003c/li\u003e\n        \u003cli\u003eServer Software: \u003c?php echo $_SERVER['SERVER_SOFTWARE']; ?\u003e\u003c/li\u003e\n        \u003cli\u003eClient Info: \u003c?php echo $_SERVER['HTTP_USER_AGENT']; ?\u003e\u003c/li\u003e\n        \u003cli\u003eRemote Address: \u003c?php echo $_SERVER['REMOTE_ADDR']; ?\u003e\u003c/li\u003e\n        \u003cli\u003eRemote Port: \u003c?php echo $_SERVER['REMOTE_PORT']; ?\u003e\u003c/li\u003e\n    \u003c/ul\u003e\n\u003c/body\u003e\n\n\u003c/html\u003e\n```\n\n- php-revision/src/010_get_post.php\n```\n\u003c?php\n/* --- $_GET \u0026 $_POST Superglobals -- */\n\n/*\n    We can pass data through urls and forms using the $_GET and $_POST superglobals.\n*/\n\n// echo $_GET['name'] . '\u003cbr/\u003e';\n// echo $_GET['age'] . '\u003cbr/\u003e';\n\nif ($_POST['submit'])\n{\n    echo $_POST['name'] . '\u003cbr/\u003e';\n    echo $_POST['age'] . '\u003cbr/\u003e';\n}\n\n\n?\u003e\n\n\u003ca href=\"\u003c?php echo $_SERVER['PHP_SELF']; ?\u003e?name=MAK\u0026age=22\"\u003e\n    Click\n\u003c/a\u003e\n\n\u003cform action=\"\u003c?php echo $_SERVER['PHP_SELF']; ?\u003e\" method=\"POST\"\u003e\n    \u003cdiv\u003e\n        \u003clabel for=\"name\"\u003eName: \u003c/label\u003e\n        \u003cinput type=\"text\" name=\"name\" /\u003e\n    \u003c/div\u003e\n    \u003cdiv\u003e\n        \u003clabel for=\"age\"\u003eAge: \u003c/label\u003e\n        \u003cinput type=\"text\" name=\"age\" /\u003e\n    \u003c/div\u003e\n    \u003cinput type=\"submit\" value=\"submit\" name=\"submit\"\u003e\n\u003c/form\u003e\n```\n\n- php-revision/src/011_sanitizing_inputs.php\n  - `htmlspecialchars()` // Convert special characters to HTML entities\n  - `filter_var()` // Sanitize data\n  - `filter_input()` // Sanitize inputs\n  - `FILTER_SANITIZE_STRING` // Convert string to string with only alphanumeric, whitespace, and the following characters - _.:/\n    - `FILTER_SANITIZE_EMAIL` // Convert string to a valid email address\n    - `FILTER_SANITIZE_URL` // Convert string to a valid URL\n    - `FILTER_SANITIZE_NUMBER_INT` // Convert string to an integer\n    - `FILTER_SANITIZE_NUMBER_FLOAT` // Convert string to a float\n    - `FILTER_SANITIZE_FULL_SPECIAL_CHARS` // HTML-encodes special characters, keeps spaces and most other characters\n\n```\n\u003c?php\n/* --- Sanitizing Inputs -- */\n\n/*\n    Data submitted through a form is not sanitized by default. We have methods to sanitize data manually.\n*/\n\nif (isset($_POST['submit'])) {\n  // $name = $_POST['email'];\n  // $email = $_POST['email'];\n\n  // htmlspecialchars() - Convert special characters to HTML entities\n  // $name = htmlspecialchars($_POST['name']);\n  // $email = htmlspecialchars($_POST['email']);\n\n  // filter_var() - Sanitize data\n  // $name = filter_var($_POST['name'], FILTER_SANITIZE_FULL_SPECIAL_CHARS);\n  // $email = filter_var($_POST['email'], FILTER_SANITIZE_EMAIL);\n\n  // filter_input() - Sanitize inputs\n    $name = filter_input(INPUT_POST, 'name', FILTER_SANITIZE_FULL_SPECIAL_CHARS);\n    $email = filter_input(INPUT_POST, 'email', FILTER_SANITIZE_EMAIL);\n\n  // FILTER_SANITIZE_STRING - Convert string to string with only alphanumeric, whitespace, and the following characters - _.:/\n  // FILTER_SANITIZE_EMAIL - Convert string to a valid email address\n  // FILTER_SANITIZE_URL - Convert string to a valid URL\n  // FILTER_SANITIZE_NUMBER_INT - Convert string to an integer\n  // FILTER_SANITIZE_NUMBER_FLOAT - Convert string to a float\n  // FILTER_SANITIZE_FULL_SPECIAL_CHARS - HTML-encodes special characters, keeps spaces and most other characters\n} ?\u003e\n\n\u003c!-- Pass data through a form --\u003e\n\u003c!-- php_self can be used for xss --\u003e\n\u003cform action=\"\u003c?php echo htmlspecialchars(\n    $_SERVER['PHP_SELF']\n); ?\u003e\" method=\"POST\"\u003e\n\u003cdiv\u003e\n    \u003clabel\u003eName: \u003c/label\u003e\n    \u003cinput type=\"text\" name=\"name\"\u003e\n\u003c/div\u003e\n\u003cbr\u003e\n\u003c?php echo $email; ?\u003e\n\u003cdiv\u003e\n\u003clabel\u003eEmail: \u003c/label\u003e\n    \u003cinput type=\"email\" name=\"email\"\u003e\n\u003c/div\u003e\n\u003cbr\u003e\n    \u003cinput type=\"submit\" name=\"submit\" value=\"Submit\"\u003e\n\u003c/form\u003e\n```\n\n- php-revision/src/012_cookies.php\n  - `$_COOKIE` // get cookie\n  - `setcookie('name', 'MAK', time() + 86400);` // set a cookie - first parameter is name second is value and third is expiry - time() = current time (86400 second are equal to one minute)\n```\n\u003c?php\n/* ------------- Cookies ------------ */\n\n/*\n    Cookies are a mechanism for storing data in the remote browser and thus tracking or identifying return users. You can set specific data to be stored in the browser, and then retrieve it when the user visits the site again.\n*/\n\nsetcookie('name', 'MAK', time() + 86400); // set a cookie - first parameter is name second is value and third is expiry - time() = current time (86400 second are equal to one minute)\n\nif (isset($_COOKIE('name')))\n{\n    echo $_COOKIE('name');\n}\n\nsetcookie('name', '', time() - 86400)\n\n?\u003e\n```\n\n- php-revision/src/013_sessions.php\n  - `$_SESSION` // get session\n  - `$_SESSION['username'] = $username;` // set a session - simple assign it to any value\n  - `header('Location: some-page');` // redirect to other page\n  - `session_start();` // to start a session - must use if you want to use a session\n  - `session_destroy();` // to end a session\n```\n\u003c?php\n/* ------------ Sessions ------------ */\n\n/*\n  Sessions are a way to store information (in variables) to be used across multiple pages.\n  Unlike cookies, sessions are stored on the server.\n*/\n\nsession_start(); // Must be called before accessing any session data\n\nif (isset($_POST['submit'])) {\n    $username = filter_input(\n        INPUT_POST,\n        'username',\n        FILTER_SANITIZE_FULL_SPECIAL_CHARS\n    );\n    $password = filter_input(\n        INPUT_POST,\n        'password',\n        FILTER_SANITIZE_FULL_SPECIAL_CHARS\n    );\n\n    if ($username == 'brad' \u0026\u0026 $password == 'password') {\n        // Set Session variable\n        $_SESSION['username'] = $username;\n        // Redirect user to another page\n        // header('Location: some-page');\n    } else {\n        echo 'Incorrect username or password';\n    }\n}\n?\u003e\n\n\u003cform action=\"\u003c?php echo htmlspecialchars(\n    $_SERVER['PHP_SELF']\n); ?\u003e\" method=\"POST\"\u003e\n    \u003cdiv\u003e\n    \u003clabel\u003eUsername: \u003c/label\u003e\n    \u003cinput type=\"text\" name=\"username\"\u003e\n    \u003c/div\u003e\n    \u003cbr\u003e\n    \u003cdiv\u003e\n    \u003clabel\u003ePassword: \u003c/label\u003e\n    \u003cinput type=\"password\" name=\"password\"\u003e\n    \u003c/div\u003e\n    \u003cbr\u003e\n    \u003cinput type=\"submit\" name=\"submit\" value=\"Submit\"\u003e\n\u003c/form\u003e\n```\n\n- php-revision/src/014_file_handling.php\n  - `file_exists` // if file exist\n  - `fopen` // open a file - required file path and permission - 'r' Read | 'w' Write\n  - `fread` // read a file;\n  - `fclose` // close a file\n  - `fwrite` // write a file\n\n```\n\u003c?php\n\n/* ---------- File Handling --------- */\n\n/* \n    File handling is the ability to read and write files on the server.\n    PHP has built in functions for reading and writing files.\n*/\n\n$file = 'some_path/users.txt';\n\nif (file_exists($file))\n{\n    // echo readfile($file);\n    $handle = fopen($file, 'r');\n    $contents = fread($handle, filesize($file));\n    fclose($handle);\n    echo $contents;\n} else {\n    $handle = fopen($file, 'w');\n    $contents = 'MAK' . PHP_EOL . 'MARIA' . PHP_EOL  . 'ALI';\n    fwrite($handle, $contents);\n    fclose($handle);\n}\n\n?\u003e\n```\n\n- php-revision/src/015_file_upload.php\n  - `$_FILES` // get a file\n  - `$_FILES['upload']['name']` // file name\n  - `$_FILES['upload']['size']` // file size\n  - `$_FILES['upload']['tmp_name']` // file tmp_name\n  - `move_uploaded_file` // upload a file in the folder structure\n```\n\u003c?php\n/* ----------- File upload ---------- */\n\n\n$allowed_ext = array('png', 'jpg', 'jpeg', 'gif');\n\nif(isset($_POST['submit'])) {\n    // Check if file was uploaded\n    if(!empty($_FILES['upload']['name'])) {\n        $file_name = $_FILES['upload']['name'];\n        $file_size = $_FILES['upload']['size'];\n        $file_tmp = $_FILES['upload']['tmp_name'];\n        $target_dir = \"uploads/$file_name\";\n        // Get file extension\n        $file_ext = explode('.', $file_name);\n        $file_ext = strtolower(end($file_ext));\n        // echo $file_ext;\n\n        // Validate file type/extension\n        if(in_array($file_ext, $allowed_ext)) {\n        // Validate file size\n        if($file_size \u003c= 1000000) { // 1000000 bytes = 1MB\n            // Upload file\n            move_uploaded_file($file_tmp, $target_dir);\n\n            // Success message\n            echo '\u003cp style=\"color: green;\"\u003eFile uploaded!\u003c/p\u003e';\n        } else {\n            echo '\u003cp style=\"color: red;\"\u003eFile too large!\u003c/p\u003e';\n        }\n        } else {\n            $message = '\u003cp style=\"color: red;\"\u003eInvalid file type!\u003c/p\u003e';\n        }\n    } else {\n        $message = '\u003cp style=\"color: red;\"\u003ePlease choose a file\u003c/p\u003e';\n    }\n}\n?\u003e\n\n\u003c!DOCTYPE html\u003e\n\u003chtml lang=\"en\"\u003e\n\u003chead\u003e\n    \u003cmeta charset=\"UTF-8\"\u003e\n    \u003cmeta http-equiv=\"X-UA-Compatible\" content=\"IE=edge\"\u003e\n    \u003cmeta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\"\u003e\n    \u003ctitle\u003eFile Upload\u003c/title\u003e\n\u003c/head\u003e\n\u003cbody\u003e\n    \u003c?php echo $message ?? null; ?\u003e\n\u003cform action=\"\u003c?php echo htmlspecialchars(\n    $_SERVER['PHP_SELF']\n); ?\u003e\" method=\"post\" enctype=\"multipart/form-data\"\u003e\n    Select image to upload:\n\u003cinput type=\"file\" name=\"upload\"\u003e\n\u003cinput type=\"submit\" value=\"Submit\" name=\"submit\"\u003e\n\u003c/form\u003e\n\u003c/body\u003e\n\u003c/html\u003e\n```\n\n- php-revision/src/016_exception.php\n  - `throw new Exception` // add a new error\n  - `try` // we will try things here - code which we want to run\n  - `catch (Exception $e)` // only if code break it will get here\n  - `finally` // always run no matter what you do in try or catch - optional\n```\n\u003c?php\n\n/* ----------- Exceptions ----------- */\n\n/*\n    PHP has an exception model similar to that of other programming languages. An exception can be thrown, and caught (\"catched\") within PHP. Code may be surrounded in a try block, to facilitate the catching of potential exceptions. Each try must have at least one corresponding catch or finally block.\n*/\n\nfunction inverse($x)\n{\n    if (!$x) \n    {\n        throw new Exception('Division by zero');\n    }\n\n    return 1/$x;\n}\n\n\ntry {\n    echo inverse(5);\n    echo inverse(0);\n} catch (Exception $e) {\n    echo 'Catch Exception' . $e-\u003egetMessage(). ' ';\n} finally {\n    echo 'first finally';\n}\n\necho 'hello world';\n\n?\u003e\n\n```\n\n- php-revision/src/017_oop.php\n  - `class` // class are like object we can create them to use them multiple times\n  -  `Access Modifiers` // public, private, protected\n  - `public` // can be accessed from anywhere\n  - `private` // can only be accessed from inside the class\n  - `protected` // can only be accessed from inside the class and by inheriting classes\n  - `extends` // you can Inherit any class using extends keyword and you can now use protected and public method here\n  - `parent::` // access any parent method\n```\n\u003c?php \n/* --- Object Oriented Programming -- */\n\n/*\n    From PHP5 onwards you can write PHP in either a procedural or object oriented way. OOP consists of classes that can hold \"properties\" and \"methods\". Objects can be created from classes.\n*/\n\nclass User {\n    // Properties are just variables that belong to a class.\n    // Access Modifiers: public, private, protected\n    // public - can be accessed from anywhere\n    // private - can only be accessed from inside the class\n    // protected - can only be accessed from inside the class and by inheriting classes\n    private $name;\n    public $email;\n    public $password;\n\n    // The constructor is called whenever an object is created from the class.\n    // We pass in properties to the constructor from the outside.\n    public function __construct($name, $email, $password) {\n        // We assign the properties passed in from the outside to the properties we created inside the class.\n        $this-\u003ename = $name;\n        $this-\u003eemail = $email;\n        $this-\u003epassword = $password;\n    }\n\n\n    // Methods are functions that belong to a class.\n    public function set_name($name) {\n        $this-\u003ename = $name;\n    }\n\n    function get_name() {\n        return $this-\u003ename;\n    }\n}\n\n$user1 = new User('Moiz', 'moiz@test.com', 'some-password');\n$user2 = new User('Maria', 'moiz@test.com', 'some-password');\n\n// $user1-\u003ename = 'MAK'; // you can't access a protected property\n$user2-\u003eset_name('MAK');\n\nvar_dump($user1);\n\necho $user2-\u003eget_name();\n\n// Inheritance\n\nclass employee extends User {\n\n    private $title;\n\n    public function __construct($name, $email, $password, $title)\n    {\n        parent::__construct($name, $email, $password);\n\n        $this-\u003etitle = $title;\n    }\n\n    public function get_title()\n    {\n        return $this-\u003etitle;\n    }\n}\n\n$employ1 = new employee('moiz ali', 'moiz.ali@test.com', 'someCoolPassword123!', 'Software Engineer'); \n\n// var_dump($employ1);\n\necho $employ1-\u003eget_title();\n\n```\n\n- `includes` // use to include a file - no error if file not found\n- `require` // use to include a file - error if file not found\n- `require_one` // use to include a file - if already include then doesn't include twice\n\n## Logical Operators\n- `\u003c` = less than\n-  `\u003e` = greater than\n-  `\u003c=` = less than or equal to\n-  `\u003e=` = greater than or equal to\n-  `==` = equal to\n-  `===` = identical to\n-  `!` = not comparison\n-  `!=` = mot equal to\n-  `!==` = not identical to\n-  `?` = (in ternary operator) if\n-  `:` = (in ternary operator) else\n-  `??` = or comparison\n-  `\u0026\u0026` = and comparison\n-  `||` = or comparison\n\n## Style Guide\n- `//` this is a single line comment = use for single line comments\n- `/*\n    this is a multi-line\n    comment\n  */` = use for multi line comments\n- `kabab case` is recommended in `PHP`, eg: my_app.\n- `PHP` ignore `white spaces` so you can hit the enter button as much as you want - ( not recommended )\n- `inc` use for component folder\n\n## Resources\nI start my journey using this cool stuff so shout to them:\n- https://www.youtube.com/watch?v=BUCiSSyIGGU\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmakstyle119%2Fphp","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmakstyle119%2Fphp","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmakstyle119%2Fphp/lists"}