From 56a2fbe668e4af9a6c47954aa2e2534d3ac631a1 Mon Sep 17 00:00:00 2001 From: Abdullah Al Mamun Roni Date: Mon, 19 Jul 2021 18:31:29 +0600 Subject: [PATCH] Folder Structure Updated --- .gitignore | 2 + Arrays/.gitignore | 1 + Arrays/README.md | 0 Arrays/array_change_key_case.php | 50 +++++ Arrays/array_chunk.php | 57 +++++ Arrays/array_column.php | 54 +++++ Arrays/array_combine.php | 35 +++ Arrays/array_count_values.php | 31 +++ Arrays/array_diff.php | 30 +++ Arrays/array_fill.php | 33 +++ Arrays/array_filter.php | 64 ++++++ Arrays/array_flip.php | 39 ++++ Arrays/array_keys.php | 36 +++ Arrays/array_map.php | 63 ++++++ Arrays/array_merge.php | 88 ++++++++ Arrays/array_pop.php | 36 +++ Arrays/array_push.php | 36 +++ Arrays/array_rand.php | 38 ++++ Arrays/array_reverse.php | 39 ++++ Arrays/array_slice.php | 43 ++++ Arrays/array_sum.php | 25 +++ Arrays/array_unique.php | 41 ++++ Arrays/arsort.php | 45 ++++ Arrays/asort.php | 45 ++++ Arrays/count.php | 29 +++ Arrays/current.php | 32 +++ Arrays/end.php | 32 +++ Arrays/in_array.php | 33 +++ Arrays/krsort.php | 45 ++++ Arrays/ksort.php | 45 ++++ Arrays/range.php | 36 +++ Arrays/reset.php | 40 ++++ Arrays/rsort.php | 46 ++++ Arrays/shuffle.php | 39 ++++ Arrays/sizeof.php | 27 +++ Arrays/sort.php | 43 ++++ Basic/.gitignore | 1 + Basic/array.php | 153 +++++++++++++ Basic/comment.php | 14 ++ Basic/constants.php | 46 ++++ Basic/data-type.php | 55 +++++ Basic/dates.php | 14 ++ Basic/functions.php | 38 ++++ Basic/hello.php | 65 ++++++ Basic/math.php | 69 ++++++ Basic/operators.php | 85 ++++++++ Basic/quotations.php | 13 ++ Basic/rand.php | 19 ++ Basic/strings.php | 21 ++ Basic/variables.php | 22 ++ Command Line/artisan.php | 101 +++++++++ Control Flow/.gitignore | 1 + Control Flow/README.md | 0 Control Flow/continue-break.php | 1 + Control Flow/if-else.php | 21 ++ Control Flow/switch-case.php | 53 +++++ Cookies/.gitignore | 1 + Cookies/.htaccess | 2 + Cookies/README.md | 0 Cookies/cookies.txt | 13 ++ Cookies/index.php | 84 +++++++ Design Pattern/.gitignore | 1 + Design Pattern/Creational/Abstract.php | 104 +++++++++ Encryption/.gitignore | 1 + Encryption/base64.php | 31 +++ Encryption/bin_hex.php | 30 +++ Encryption/hash.php | 23 ++ Encryption/salt.php | 18 ++ Encryption/string.php | 31 +++ Exceptions/.gitignore | 0 Exceptions/ErrorHandler.php | 20 ++ Exceptions/PDOException.php | 35 +++ Exceptions/README.md | 7 + Exceptions/TryCatch.php | 78 +++++++ Exceptions/TryCatchFinally.php | 36 +++ File Handling/.gitignore | 1 + File Handling/copy.php | 0 File Handling/create.php | 0 File Handling/delete.php | 0 File Handling/directory.php | 0 File Handling/open.php | 0 File Handling/path.php | 0 File Handling/read.php | 0 File Handling/write.php | 0 Form Handling/.gitignore | 1 + Form Handling/file.php | 60 +++++ Form Handling/get.php | 96 ++++++++ Form Handling/post.php | 96 ++++++++ Form Handling/request.php | 102 +++++++++ Functions/.gitignore | 1 + Functions/Anonymous.php | 1 + Functions/Argument.php | 50 +++++ Functions/Arrow.php | 47 ++++ Functions/Closure.php | 86 ++++++++ Functions/Declaration.php | 1 + Functions/README.md | 39 ++++ Functions/Recursive.php | 109 +++++++++ Functions/Scope.php | 43 ++++ Iteration/.gitignore | 1 + Iteration/README.md | 0 Iteration/do-while.php | 44 ++++ Iteration/for.php | 32 +++ Iteration/foreach.php | 33 +++ Iteration/while.php | 41 ++++ JSON/README.md | 0 JSON/app/Controllers/JsonCrudController.php | 117 ++++++++++ JSON/app/Models/users.json | 32 +++ JSON/index.php | 206 ++++++++++++++++++ OOP/.gitignore | 1 + OOP/Abstract/AbstractClass.php | 6 + OOP/Abstract/README.md | 45 ++++ OOP/Abstract/Students.php | 25 +++ OOP/AccessModifier/PrivateModifier.php | 22 ++ OOP/AccessModifier/ProtectedModifier.php | 31 +++ OOP/AccessModifier/PublicModifier.php | 21 ++ OOP/AccessModifier/README.md | 44 ++++ OOP/Autoload/Autoload.php | 49 +++++ OOP/Autoload/Controllers/CreateController.php | 9 + OOP/Autoload/Controllers/DeleteController.php | 9 + OOP/Autoload/Controllers/ReadController.php | 9 + OOP/Autoload/Controllers/UpdateController.php | 9 + OOP/Autoload/README.md | 62 ++++++ OOP/Basic/Constructor.php | 18 ++ OOP/Basic/Destructor.php | 18 ++ OOP/Basic/House.php | 41 ++++ OOP/Basic/README.md | 57 +++++ OOP/Database/Database.php | 171 +++++++++++++++ OOP/Database/DatabaseController.php | 7 + OOP/Database/README.md | 66 ++++++ OOP/Dependency Injection/Author.php | 31 +++ OOP/Dependency Injection/Book.php | 41 ++++ OOP/Dependency Injection/Publisher.php | 37 ++++ OOP/Dependency Injection/index.php | 11 + OOP/Functions/Conditional/ExtendedClass.php | 11 + OOP/Functions/Conditional/SimpleClass.php | 10 + OOP/Functions/Conditional/SimpleInterface.php | 7 + OOP/Functions/Conditional/SimpleTrait.php | 13 ++ OOP/Functions/ConditionalFunction.php | 68 ++++++ OOP/Functions/Get/Activities.php | 47 ++++ OOP/Functions/Get/ActivitiesInterface.php | 8 + OOP/Functions/Get/ActivitiesTrait.php | 15 ++ OOP/Functions/Get/ExtendActivities.php | 43 ++++ OOP/Functions/GetFunction.php | 54 +++++ OOP/Functions/README.md | 140 ++++++++++++ OOP/Inheritance/BalanceSheet.php | 29 +++ .../Controllers/AccountController.php | 27 +++ .../Controllers/ProfileController.php | 19 ++ .../Controllers/SalarySheetController.php | 29 +++ OOP/Inheritance/EmployeeProfile.php | 16 ++ OOP/Inheritance/ManagerProfile.php | 14 ++ OOP/Inheritance/README.md | 81 +++++++ OOP/Interface/Employees.php | 56 +++++ OOP/Interface/HumanResourceInterfaces.php | 9 + OOP/Interface/Managers.php | 56 +++++ OOP/Interface/README.md | 62 ++++++ OOP/MagicConstant/ConstantClass.php | 20 ++ OOP/MagicConstant/ConstantNameSpace.php | 16 ++ OOP/MagicConstant/ConstantTrait.php | 18 ++ OOP/MagicConstant/Constants.php | 33 +++ OOP/MagicConstant/README.md | 78 +++++++ OOP/MagicConstant/functions.php | 12 + OOP/MagicMethod/Call/Call.php | 43 ++++ OOP/MagicMethod/Call/CallStatic.php | 17 ++ OOP/MagicMethod/Call/README.md | 0 OOP/MagicMethod/Clone/Clone.php | 34 +++ OOP/MagicMethod/Clone/README.md | 0 OOP/MagicMethod/Invoke/Invoke.php | 72 ++++++ OOP/MagicMethod/Invoke/README.md | 0 OOP/MagicMethod/Isset/Isset.php | 44 ++++ OOP/MagicMethod/Isset/README.md | 0 OOP/MagicMethod/Sleep/README.md | 0 OOP/MagicMethod/Sleep/SleepMethod.php | 51 +++++ OOP/MagicMethod/Unset/README.md | 0 OOP/MagicMethod/Unset/UnsetMethod.php | 71 ++++++ OOP/MagicMethod/Wakeup/README.md | 0 OOP/MagicMethod/Wakeup/WakeupMethod.php | 14 ++ OOP/MethodChaining/Eloquent.php | 58 +++++ OOP/MethodChaining/ObjectRelation.php | 61 ++++++ OOP/MethodChaining/README.md | 61 ++++++ OOP/Namespace/Downloader.php | 10 + OOP/Namespace/Library/Excel/GenerateFile.php | 11 + OOP/Namespace/Library/PDF/GenerateFile.php | 13 ++ OOP/Namespace/README.md | 51 +++++ OOP/Pagination/PaginationController.php | 53 +++++ OOP/Pagination/README.md | 11 + .../Abstract/CelsiusToFahrenheit.php | 19 ++ .../Abstract/FahrenheitToCelsius.php | 19 ++ OOP/Polymorphism/Abstract/Temperature.php | 7 + OOP/Polymorphism/Interface/Circle.php | 19 ++ OOP/Polymorphism/Interface/Rectangle.php | 21 ++ OOP/Polymorphism/Interface/ShapeGenerate.php | 6 + OOP/Polymorphism/Interface/Triangle.php | 21 ++ OOP/Polymorphism/Polymorphism.php | 31 +++ OOP/Polymorphism/README.md | 69 ++++++ OOP/README.md | 30 +++ OOP/Static/BankAccount.php | 28 +++ OOP/Static/Controllers/Profile.php | 30 +++ OOP/Static/Late Static Binding/ChildClass.php | 12 + .../Late Static Binding/ParentClass.php | 16 ++ OOP/Static/README.md | 84 +++++++ OOP/Static/SalaryStatement.php | 41 ++++ OOP/Static/TeacherProfile.php | 13 ++ OOP/Traits/Traits.php | 190 ++++++++++++++++ OOP/TypeHinting/Example1.php | 62 ++++++ OOP/TypeHinting/Example2.php | 1 + README.md | 30 +++ REGEX/.gitignore | 1 + REGEX/README.md | 97 +++++++++ REGEX/introduction.php | 0 Server Config/.htaccess | 179 +++++++++++++++ Server Config/PreventWebsiteCopier.php | 179 +++++++++++++++ Session/.gitignore | 1 + Session/.htaccess | 2 + Session/README.md | 0 Session/index.php | 88 ++++++++ Session/session.txt | 20 ++ Solid Principle/.gitignore | 1 + Solid Principle/README.md | 114 ++++++++++ .../dependency-inversion/index.php | 1 + .../Appropriate/Animals/Animal.php | 8 + .../Appropriate/Animals/Bird.php | 8 + .../Appropriate/Animals/Dog.php | 8 + .../Appropriate/Animals/Human.php | 8 + .../Appropriate/Files/Excel.php | 8 + .../Appropriate/Files/File.php | 8 + .../Appropriate/Files/Json.php | 8 + .../Irrelevant/Animals/Animal.php | 8 + .../Irrelevant/Animals/Bird.php | 8 + .../Irrelevant/Animals/Dog.php | 8 + .../Irrelevant/Animals/Human.php | 8 + .../Irrelevant/Files/Excel.php | 28 +++ .../Irrelevant/Files/File.php | 10 + .../Irrelevant/Files/Json.php | 26 +++ .../interface-segregation/index.php | 9 + .../liskov-substitution/ConditionExample.php | 53 +++++ .../classes/ChildClass.php | 8 + .../classes/ParentClass.php | 8 + Solid Principle/liskov-substitution/index.php | 5 + .../open-closed/Calculator/Circle.php | 20 ++ .../Calculator/ShapeCalculator.php | 8 + .../open-closed/Calculator/Square.php | 20 ++ .../open-closed/Calculator/Triangle.php | 22 ++ .../Controllers/ShapeGenerator.php | 26 +++ Solid Principle/open-closed/index.php | 15 ++ .../Controllers/AreaCalculator.php | 34 +++ .../appropriate/Controllers/HumanResource.php | 26 +++ .../appropriate/Repositories/area/Circle.php | 24 ++ .../appropriate/Repositories/area/Square.php | 24 ++ .../Repositories/area/Triangle.php | 26 +++ .../Repositories/data/Employee.php | 31 +++ .../appropriate/Repositories/data/Payroll.php | 29 +++ .../single-responsibility/index.php | 49 +++++ .../irrelevant/SalaryGenerator.php | 56 +++++ .../irrelevant/ShapeCalculator.php | 43 ++++ Strings/.gitignore | 1 + Strings/README.md | 0 Strings/addslashes.php | 52 +++++ Strings/chunk_split.php | 24 ++ Strings/explode.php | 25 +++ Strings/implode.php | 25 +++ Strings/join.php | 24 ++ Strings/sprintf.php | 48 ++++ Strings/str_pad.php | 33 +++ Strings/str_repeat.php | 22 ++ Strings/str_replace.php | 51 +++++ Strings/str_shuffle.php | 21 ++ Strings/str_split.php | 23 ++ Strings/str_word_count.php | 22 ++ Strings/strcases.php | 67 ++++++ Strings/strcmp.php | 22 ++ Strings/strip_tags.php | 25 +++ Strings/stripslashes.php | 39 ++++ Strings/strpos.php | 75 +++++++ Strings/substr.php | 23 ++ Strings/trim.php | 31 +++ Utilities/AndroidNotification.php | 88 ++++++++ Utilities/DateManipulation.php | 111 ++++++++++ Utilities/DistanceCalculator.php | 43 ++++ Utilities/InvoiceAmount.php | 57 +++++ Utilities/OnnoRokomSMS.php | 61 ++++++ cURL/.gitignore | 1 + cURL/README.md | 0 cURL/web-scrapping.php | 1 + php.png | Bin 0 -> 9428 bytes 284 files changed, 9565 insertions(+) create mode 100644 .gitignore create mode 100644 Arrays/.gitignore create mode 100644 Arrays/README.md create mode 100644 Arrays/array_change_key_case.php create mode 100644 Arrays/array_chunk.php create mode 100644 Arrays/array_column.php create mode 100644 Arrays/array_combine.php create mode 100644 Arrays/array_count_values.php create mode 100644 Arrays/array_diff.php create mode 100644 Arrays/array_fill.php create mode 100644 Arrays/array_filter.php create mode 100644 Arrays/array_flip.php create mode 100644 Arrays/array_keys.php create mode 100644 Arrays/array_map.php create mode 100644 Arrays/array_merge.php create mode 100644 Arrays/array_pop.php create mode 100644 Arrays/array_push.php create mode 100644 Arrays/array_rand.php create mode 100644 Arrays/array_reverse.php create mode 100644 Arrays/array_slice.php create mode 100644 Arrays/array_sum.php create mode 100644 Arrays/array_unique.php create mode 100644 Arrays/arsort.php create mode 100644 Arrays/asort.php create mode 100644 Arrays/count.php create mode 100644 Arrays/current.php create mode 100644 Arrays/end.php create mode 100644 Arrays/in_array.php create mode 100644 Arrays/krsort.php create mode 100644 Arrays/ksort.php create mode 100644 Arrays/range.php create mode 100644 Arrays/reset.php create mode 100644 Arrays/rsort.php create mode 100644 Arrays/shuffle.php create mode 100644 Arrays/sizeof.php create mode 100644 Arrays/sort.php create mode 100644 Basic/.gitignore create mode 100644 Basic/array.php create mode 100644 Basic/comment.php create mode 100644 Basic/constants.php create mode 100644 Basic/data-type.php create mode 100644 Basic/dates.php create mode 100644 Basic/functions.php create mode 100644 Basic/hello.php create mode 100644 Basic/math.php create mode 100644 Basic/operators.php create mode 100644 Basic/quotations.php create mode 100644 Basic/rand.php create mode 100644 Basic/strings.php create mode 100644 Basic/variables.php create mode 100644 Command Line/artisan.php create mode 100644 Control Flow/.gitignore create mode 100644 Control Flow/README.md create mode 100644 Control Flow/continue-break.php create mode 100644 Control Flow/if-else.php create mode 100644 Control Flow/switch-case.php create mode 100644 Cookies/.gitignore create mode 100644 Cookies/.htaccess create mode 100644 Cookies/README.md create mode 100644 Cookies/cookies.txt create mode 100644 Cookies/index.php create mode 100644 Design Pattern/.gitignore create mode 100644 Design Pattern/Creational/Abstract.php create mode 100644 Encryption/.gitignore create mode 100644 Encryption/base64.php create mode 100644 Encryption/bin_hex.php create mode 100644 Encryption/hash.php create mode 100644 Encryption/salt.php create mode 100644 Encryption/string.php create mode 100644 Exceptions/.gitignore create mode 100644 Exceptions/ErrorHandler.php create mode 100644 Exceptions/PDOException.php create mode 100644 Exceptions/README.md create mode 100644 Exceptions/TryCatch.php create mode 100644 Exceptions/TryCatchFinally.php create mode 100644 File Handling/.gitignore create mode 100644 File Handling/copy.php create mode 100644 File Handling/create.php create mode 100644 File Handling/delete.php create mode 100644 File Handling/directory.php create mode 100644 File Handling/open.php create mode 100644 File Handling/path.php create mode 100644 File Handling/read.php create mode 100644 File Handling/write.php create mode 100644 Form Handling/.gitignore create mode 100644 Form Handling/file.php create mode 100644 Form Handling/get.php create mode 100644 Form Handling/post.php create mode 100644 Form Handling/request.php create mode 100644 Functions/.gitignore create mode 100644 Functions/Anonymous.php create mode 100644 Functions/Argument.php create mode 100644 Functions/Arrow.php create mode 100644 Functions/Closure.php create mode 100644 Functions/Declaration.php create mode 100644 Functions/README.md create mode 100644 Functions/Recursive.php create mode 100644 Functions/Scope.php create mode 100644 Iteration/.gitignore create mode 100644 Iteration/README.md create mode 100644 Iteration/do-while.php create mode 100644 Iteration/for.php create mode 100644 Iteration/foreach.php create mode 100644 Iteration/while.php create mode 100644 JSON/README.md create mode 100644 JSON/app/Controllers/JsonCrudController.php create mode 100644 JSON/app/Models/users.json create mode 100644 JSON/index.php create mode 100644 OOP/.gitignore create mode 100644 OOP/Abstract/AbstractClass.php create mode 100644 OOP/Abstract/README.md create mode 100644 OOP/Abstract/Students.php create mode 100644 OOP/AccessModifier/PrivateModifier.php create mode 100644 OOP/AccessModifier/ProtectedModifier.php create mode 100644 OOP/AccessModifier/PublicModifier.php create mode 100644 OOP/AccessModifier/README.md create mode 100644 OOP/Autoload/Autoload.php create mode 100644 OOP/Autoload/Controllers/CreateController.php create mode 100644 OOP/Autoload/Controllers/DeleteController.php create mode 100644 OOP/Autoload/Controllers/ReadController.php create mode 100644 OOP/Autoload/Controllers/UpdateController.php create mode 100644 OOP/Autoload/README.md create mode 100644 OOP/Basic/Constructor.php create mode 100644 OOP/Basic/Destructor.php create mode 100644 OOP/Basic/House.php create mode 100644 OOP/Basic/README.md create mode 100644 OOP/Database/Database.php create mode 100644 OOP/Database/DatabaseController.php create mode 100644 OOP/Database/README.md create mode 100644 OOP/Dependency Injection/Author.php create mode 100644 OOP/Dependency Injection/Book.php create mode 100644 OOP/Dependency Injection/Publisher.php create mode 100644 OOP/Dependency Injection/index.php create mode 100644 OOP/Functions/Conditional/ExtendedClass.php create mode 100644 OOP/Functions/Conditional/SimpleClass.php create mode 100644 OOP/Functions/Conditional/SimpleInterface.php create mode 100644 OOP/Functions/Conditional/SimpleTrait.php create mode 100644 OOP/Functions/ConditionalFunction.php create mode 100644 OOP/Functions/Get/Activities.php create mode 100644 OOP/Functions/Get/ActivitiesInterface.php create mode 100644 OOP/Functions/Get/ActivitiesTrait.php create mode 100644 OOP/Functions/Get/ExtendActivities.php create mode 100644 OOP/Functions/GetFunction.php create mode 100644 OOP/Functions/README.md create mode 100644 OOP/Inheritance/BalanceSheet.php create mode 100644 OOP/Inheritance/Controllers/AccountController.php create mode 100644 OOP/Inheritance/Controllers/ProfileController.php create mode 100644 OOP/Inheritance/Controllers/SalarySheetController.php create mode 100644 OOP/Inheritance/EmployeeProfile.php create mode 100644 OOP/Inheritance/ManagerProfile.php create mode 100644 OOP/Inheritance/README.md create mode 100644 OOP/Interface/Employees.php create mode 100644 OOP/Interface/HumanResourceInterfaces.php create mode 100644 OOP/Interface/Managers.php create mode 100644 OOP/Interface/README.md create mode 100644 OOP/MagicConstant/ConstantClass.php create mode 100644 OOP/MagicConstant/ConstantNameSpace.php create mode 100644 OOP/MagicConstant/ConstantTrait.php create mode 100644 OOP/MagicConstant/Constants.php create mode 100644 OOP/MagicConstant/README.md create mode 100644 OOP/MagicConstant/functions.php create mode 100644 OOP/MagicMethod/Call/Call.php create mode 100644 OOP/MagicMethod/Call/CallStatic.php create mode 100644 OOP/MagicMethod/Call/README.md create mode 100644 OOP/MagicMethod/Clone/Clone.php create mode 100644 OOP/MagicMethod/Clone/README.md create mode 100644 OOP/MagicMethod/Invoke/Invoke.php create mode 100644 OOP/MagicMethod/Invoke/README.md create mode 100644 OOP/MagicMethod/Isset/Isset.php create mode 100644 OOP/MagicMethod/Isset/README.md create mode 100644 OOP/MagicMethod/Sleep/README.md create mode 100644 OOP/MagicMethod/Sleep/SleepMethod.php create mode 100644 OOP/MagicMethod/Unset/README.md create mode 100644 OOP/MagicMethod/Unset/UnsetMethod.php create mode 100644 OOP/MagicMethod/Wakeup/README.md create mode 100644 OOP/MagicMethod/Wakeup/WakeupMethod.php create mode 100644 OOP/MethodChaining/Eloquent.php create mode 100644 OOP/MethodChaining/ObjectRelation.php create mode 100644 OOP/MethodChaining/README.md create mode 100644 OOP/Namespace/Downloader.php create mode 100644 OOP/Namespace/Library/Excel/GenerateFile.php create mode 100644 OOP/Namespace/Library/PDF/GenerateFile.php create mode 100644 OOP/Namespace/README.md create mode 100644 OOP/Pagination/PaginationController.php create mode 100644 OOP/Pagination/README.md create mode 100644 OOP/Polymorphism/Abstract/CelsiusToFahrenheit.php create mode 100644 OOP/Polymorphism/Abstract/FahrenheitToCelsius.php create mode 100644 OOP/Polymorphism/Abstract/Temperature.php create mode 100644 OOP/Polymorphism/Interface/Circle.php create mode 100644 OOP/Polymorphism/Interface/Rectangle.php create mode 100644 OOP/Polymorphism/Interface/ShapeGenerate.php create mode 100644 OOP/Polymorphism/Interface/Triangle.php create mode 100644 OOP/Polymorphism/Polymorphism.php create mode 100644 OOP/Polymorphism/README.md create mode 100644 OOP/README.md create mode 100644 OOP/Static/BankAccount.php create mode 100644 OOP/Static/Controllers/Profile.php create mode 100644 OOP/Static/Late Static Binding/ChildClass.php create mode 100644 OOP/Static/Late Static Binding/ParentClass.php create mode 100644 OOP/Static/README.md create mode 100644 OOP/Static/SalaryStatement.php create mode 100644 OOP/Static/TeacherProfile.php create mode 100644 OOP/Traits/Traits.php create mode 100644 OOP/TypeHinting/Example1.php create mode 100644 OOP/TypeHinting/Example2.php create mode 100644 README.md create mode 100644 REGEX/.gitignore create mode 100644 REGEX/README.md create mode 100644 REGEX/introduction.php create mode 100644 Server Config/.htaccess create mode 100644 Server Config/PreventWebsiteCopier.php create mode 100644 Session/.gitignore create mode 100644 Session/.htaccess create mode 100644 Session/README.md create mode 100644 Session/index.php create mode 100644 Session/session.txt create mode 100644 Solid Principle/.gitignore create mode 100644 Solid Principle/README.md create mode 100644 Solid Principle/dependency-inversion/index.php create mode 100644 Solid Principle/interface-segregation/Appropriate/Animals/Animal.php create mode 100644 Solid Principle/interface-segregation/Appropriate/Animals/Bird.php create mode 100644 Solid Principle/interface-segregation/Appropriate/Animals/Dog.php create mode 100644 Solid Principle/interface-segregation/Appropriate/Animals/Human.php create mode 100644 Solid Principle/interface-segregation/Appropriate/Files/Excel.php create mode 100644 Solid Principle/interface-segregation/Appropriate/Files/File.php create mode 100644 Solid Principle/interface-segregation/Appropriate/Files/Json.php create mode 100644 Solid Principle/interface-segregation/Irrelevant/Animals/Animal.php create mode 100644 Solid Principle/interface-segregation/Irrelevant/Animals/Bird.php create mode 100644 Solid Principle/interface-segregation/Irrelevant/Animals/Dog.php create mode 100644 Solid Principle/interface-segregation/Irrelevant/Animals/Human.php create mode 100644 Solid Principle/interface-segregation/Irrelevant/Files/Excel.php create mode 100644 Solid Principle/interface-segregation/Irrelevant/Files/File.php create mode 100644 Solid Principle/interface-segregation/Irrelevant/Files/Json.php create mode 100644 Solid Principle/interface-segregation/index.php create mode 100644 Solid Principle/liskov-substitution/ConditionExample.php create mode 100644 Solid Principle/liskov-substitution/classes/ChildClass.php create mode 100644 Solid Principle/liskov-substitution/classes/ParentClass.php create mode 100644 Solid Principle/liskov-substitution/index.php create mode 100644 Solid Principle/open-closed/Calculator/Circle.php create mode 100644 Solid Principle/open-closed/Calculator/ShapeCalculator.php create mode 100644 Solid Principle/open-closed/Calculator/Square.php create mode 100644 Solid Principle/open-closed/Calculator/Triangle.php create mode 100644 Solid Principle/open-closed/Controllers/ShapeGenerator.php create mode 100644 Solid Principle/open-closed/index.php create mode 100644 Solid Principle/single-responsibility/appropriate/Controllers/AreaCalculator.php create mode 100644 Solid Principle/single-responsibility/appropriate/Controllers/HumanResource.php create mode 100644 Solid Principle/single-responsibility/appropriate/Repositories/area/Circle.php create mode 100644 Solid Principle/single-responsibility/appropriate/Repositories/area/Square.php create mode 100644 Solid Principle/single-responsibility/appropriate/Repositories/area/Triangle.php create mode 100644 Solid Principle/single-responsibility/appropriate/Repositories/data/Employee.php create mode 100644 Solid Principle/single-responsibility/appropriate/Repositories/data/Payroll.php create mode 100644 Solid Principle/single-responsibility/index.php create mode 100644 Solid Principle/single-responsibility/irrelevant/SalaryGenerator.php create mode 100644 Solid Principle/single-responsibility/irrelevant/ShapeCalculator.php create mode 100644 Strings/.gitignore create mode 100644 Strings/README.md create mode 100644 Strings/addslashes.php create mode 100644 Strings/chunk_split.php create mode 100644 Strings/explode.php create mode 100644 Strings/implode.php create mode 100644 Strings/join.php create mode 100644 Strings/sprintf.php create mode 100644 Strings/str_pad.php create mode 100644 Strings/str_repeat.php create mode 100644 Strings/str_replace.php create mode 100644 Strings/str_shuffle.php create mode 100644 Strings/str_split.php create mode 100644 Strings/str_word_count.php create mode 100644 Strings/strcases.php create mode 100644 Strings/strcmp.php create mode 100644 Strings/strip_tags.php create mode 100644 Strings/stripslashes.php create mode 100644 Strings/strpos.php create mode 100644 Strings/substr.php create mode 100644 Strings/trim.php create mode 100644 Utilities/AndroidNotification.php create mode 100644 Utilities/DateManipulation.php create mode 100644 Utilities/DistanceCalculator.php create mode 100644 Utilities/InvoiceAmount.php create mode 100644 Utilities/OnnoRokomSMS.php create mode 100644 cURL/.gitignore create mode 100644 cURL/README.md create mode 100644 cURL/web-scrapping.php create mode 100644 php.png diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..331c58f --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +.idea +vendor \ No newline at end of file diff --git a/Arrays/.gitignore b/Arrays/.gitignore new file mode 100644 index 0000000..723ef36 --- /dev/null +++ b/Arrays/.gitignore @@ -0,0 +1 @@ +.idea \ No newline at end of file diff --git a/Arrays/README.md b/Arrays/README.md new file mode 100644 index 0000000..e69de29 diff --git a/Arrays/array_change_key_case.php b/Arrays/array_change_key_case.php new file mode 100644 index 0000000..23a7e2e --- /dev/null +++ b/Arrays/array_change_key_case.php @@ -0,0 +1,50 @@ + "35", "Ben" => "37", "Joe" => "43"); + +echo '
';
+print_r(array_change_key_case($userAges, CASE_UPPER));
+print_r(array_change_key_case($userAges, CASE_LOWER));
+print_r(array_change_key_case($userAges));
+echo '
'; + +/** + * The output of the code above will be: + * Array + * ( + * [PETER] => 35 + * [BEN] => 37 + * [JOE] => 43 + * ) + * + * Array + * ( + * [peter] => 35 + * [ben] => 37 + * [joe] => 43 + * ) + * + * Array + * ( + * [peter] => 35 + * [ben] => 37 + * [joe] => 43 + * ) + */ \ No newline at end of file diff --git a/Arrays/array_chunk.php b/Arrays/array_chunk.php new file mode 100644 index 0000000..41399d3 --- /dev/null +++ b/Arrays/array_chunk.php @@ -0,0 +1,57 @@ + "35", "Ben" => "37", "Joe" => "43", "Harry" => "50"); + +echo '
';
+print_r(array_chunk($users, 3, true));
+print_r(array_chunk($users, 2, false));
+echo '
'; + +/** + * The output of the code above will be: + * Array + * ( + * [0] => Array + * ( + * [Peter] => 35 + * [Ben] => 37 + * ) + * [1] => Array + * ( + * [Joe] => 43 + * [Harry] => 50 + * ) + * ) + * + * Array + * ( + * [0] => Array + * ( + * [0] => 35 + * [1] => 37 + * ) + * [1] => Array + * ( + * [0] => 43 + * [1] => 50 + * ) + * ) + */ \ No newline at end of file diff --git a/Arrays/array_column.php b/Arrays/array_column.php new file mode 100644 index 0000000..b0b7538 --- /dev/null +++ b/Arrays/array_column.php @@ -0,0 +1,54 @@ + 5698, + 'first_name' => 'Peter', + 'last_name' => 'Burgman', + ), + array( + 'id' => 4767, + 'first_name' => 'Ben', + 'last_name' => 'Smith', + ), + array( + 'id' => 3809, + 'first_name' => 'John', + 'last_name' => 'Doe', + ) +); + +$lastNames = array_column($users, 'last_name'); + +echo '
';
+print_r($lastNames);
+echo '
'; + +/** + * The output of the code above will be: + * Array + * ( + * [0] => Burgman + * [1] => Smith + * [2] => Doe + * ) + */ \ No newline at end of file diff --git a/Arrays/array_combine.php b/Arrays/array_combine.php new file mode 100644 index 0000000..ee8dbca --- /dev/null +++ b/Arrays/array_combine.php @@ -0,0 +1,35 @@ +'; +print_r($combine); +echo ''; + +/** + * The output of the code above will be: + * Array + * ( + * [Peter] => 35 + * [Smith] => 42 + * [John] => 29 + * ) + */ diff --git a/Arrays/array_count_values.php b/Arrays/array_count_values.php new file mode 100644 index 0000000..4012b02 --- /dev/null +++ b/Arrays/array_count_values.php @@ -0,0 +1,31 @@ +'; +print_r(array_count_values($fruits)); +echo ''; + +/** + * The output of the code above will be: + * Array + * ( + * [Apple] => 2 + * [Mango] => 2 + * [Banana] => 1 + * [Lemon] => 1 + * [Orange] => 1 + * [Strawberry] => 1 + * ) + */ \ No newline at end of file diff --git a/Arrays/array_diff.php b/Arrays/array_diff.php new file mode 100644 index 0000000..8d622e6 --- /dev/null +++ b/Arrays/array_diff.php @@ -0,0 +1,30 @@ + "red", "b" => "green", "c" => "blue", "d" => "yellow"); +$arr2 = array("e" => "red", "f" => "green", "g" => "blue"); + +$result = array_diff($arr1, $arr2); + +echo '
';
+print_r($result);
+echo '
'; + +/** + * The output of the code above will be: + * Array + * ( + * [d] => yellow + * ) + */ \ No newline at end of file diff --git a/Arrays/array_fill.php b/Arrays/array_fill.php new file mode 100644 index 0000000..518f35c --- /dev/null +++ b/Arrays/array_fill.php @@ -0,0 +1,33 @@ +'; +print_r($result); +echo ''; + +/** + * The output of the code above will be: + * Array + * ( + * [2] => blue + * [3] => blue + * [4] => blue + * [5] => blue + * ) + */ \ No newline at end of file diff --git a/Arrays/array_filter.php b/Arrays/array_filter.php new file mode 100644 index 0000000..be1bff2 --- /dev/null +++ b/Arrays/array_filter.php @@ -0,0 +1,64 @@ +'; +print_r($oddNum); +print_r($evenNum); +echo ''; + +/** + * The output of the code above will be: + * Array + * ( + * [1] => 2 + * [3] => 4 + * [5] => 6 + * [7] => 8 + * ) + * + * Array + * ( + * [0] => 1 + * [2] => 3 + * [4] => 5 + * [6] => 7 + * [8] => 9 + * ) + */ \ No newline at end of file diff --git a/Arrays/array_flip.php b/Arrays/array_flip.php new file mode 100644 index 0000000..105c1bd --- /dev/null +++ b/Arrays/array_flip.php @@ -0,0 +1,39 @@ + "John Doe", + "email" => "jhondoe@gmail.com", + "mobile" => "+8801316440504", + "address" => "Dhaka-1206, Bangladesh", +); + +$result = array_flip($array); + +echo '
';
+print_r($result);
+echo '
'; + +/** + * The output of the code above will be: + * Array + * ( + * [John Doe] => full_name + * [jhondoe@gmail.com] => email + * [+8801316440504] => mobile + * [Dhaka-1206, Bangladesh] => address + * ) + */ diff --git a/Arrays/array_keys.php b/Arrays/array_keys.php new file mode 100644 index 0000000..b9313c2 --- /dev/null +++ b/Arrays/array_keys.php @@ -0,0 +1,36 @@ + "XC90", + "BMW" => "X5", + "Toyota" => "Highlander", +); + +echo '
';
+print_r(array_keys($array));
+echo '
'; + +/** + * The output of the code above will be: + * Array + * ( + * [0] => Volvo + * [1] => BMW + * [2] => Toyota + * ) + */ diff --git a/Arrays/array_map.php b/Arrays/array_map.php new file mode 100644 index 0000000..4db2a72 --- /dev/null +++ b/Arrays/array_map.php @@ -0,0 +1,63 @@ +'; +print_r($example1); +print_r($example2); +echo ''; + +/** + * The output of the code above will be: + * Array + * ( + * [0] => 6 + * [1] => 7 + * [2] => 8 + * [3] => 9 + * [4] => 10 + * ) + * + * Array + * ( + * [0] => Matched + * [1] => Not matched + * [2] => Not matched + * [3] => Matched + * [4] => Not matched + * ) + */ diff --git a/Arrays/array_merge.php b/Arrays/array_merge.php new file mode 100644 index 0000000..aa7a153 --- /dev/null +++ b/Arrays/array_merge.php @@ -0,0 +1,88 @@ +'; +print_r($result); +echo ''; + +/** + * The output of the code above will be: + * Array + * ( + * [0] => Apple + * [1] => Banana + * [2] => Mango + * [3] => Lemon + * [4] => Orange + * ) + */ + + + +/** + * Definition and Usage: + * The array_merge_recursive() function merges one or + * more arrays into one array. + * + * + * Syntax: + * array_merge(array1, array2, array3, ...) + * + * array1 - Required. Specifies an array + * array2 - Required. Specifies an array + * array3 - Required. Specifies an array + * + */ + +// Example 1: +$array1 = array('a' => 'Apple', 'b' => 'Banana'); +$array2 = array('a' => 'Mango', 'b' => 'Lemon', 'c' => 'Orange'); +$result = array_merge_recursive($array1, $array2); + +echo '
';
+print_r($result);
+echo '
'; + +/** + * The output of the code above will be: + * Array + * ( + * [a] => Array + * ( + * [0] => Apple + * [1] => Mango + * ) + * [b] => Array + * ( + * [0] => Banana + * [1] => Lemon + * ) + * [c] => Orange + * ) + */ \ No newline at end of file diff --git a/Arrays/array_pop.php b/Arrays/array_pop.php new file mode 100644 index 0000000..70ba7d1 --- /dev/null +++ b/Arrays/array_pop.php @@ -0,0 +1,36 @@ +'; +print_r($fruits); +echo ''; + +/** + * The output of the code above will be: + * Orange + * + * Array + * ( + * [0] => Apple + * [1] => Banana + * [2] => Mango + * [3] => Lemon + * ) + * + */ \ No newline at end of file diff --git a/Arrays/array_push.php b/Arrays/array_push.php new file mode 100644 index 0000000..3da20f3 --- /dev/null +++ b/Arrays/array_push.php @@ -0,0 +1,36 @@ +'; +print_r($fruits); +echo ''; + +/** + * The output of the code above will be: + * Array + * ( + * [0] => Apple + * [1] => Banana + * [2] => Mango + * [3] => Lemon + * [4] => Orange + * ) + * + */ \ No newline at end of file diff --git a/Arrays/array_rand.php b/Arrays/array_rand.php new file mode 100644 index 0000000..bcfd9c8 --- /dev/null +++ b/Arrays/array_rand.php @@ -0,0 +1,38 @@ +"; +echo $fruits[$result[1]] . "
"; +echo $fruits[$result[2]] . "
"; +echo $fruits[$result[3]] . "
"; + +/** + * The output of the code above will be: + * + * Banana + * Mango + * BlackBerry + * Orange + * + * n:b: your result might be differntiate each time + * + */ \ No newline at end of file diff --git a/Arrays/array_reverse.php b/Arrays/array_reverse.php new file mode 100644 index 0000000..bd9aff3 --- /dev/null +++ b/Arrays/array_reverse.php @@ -0,0 +1,39 @@ +'; +print_r($result); +echo ''; + +/** + * The output of the code above will be: + * + * Array + * ( + * [0] => Orange + * [1] => Lemon + * [2] => Mango + * [3] => Banana + * [4] => Apple + * ) + * + */ \ No newline at end of file diff --git a/Arrays/array_slice.php b/Arrays/array_slice.php new file mode 100644 index 0000000..df73760 --- /dev/null +++ b/Arrays/array_slice.php @@ -0,0 +1,43 @@ +'; +print_r($result); +echo ''; + +/** + * The output of the code above will be: + * + * Array + * ( + * [0] => Banana + * [1] => Mango + * [2] => Lemon + * ) + * + */ \ No newline at end of file diff --git a/Arrays/array_sum.php b/Arrays/array_sum.php new file mode 100644 index 0000000..ed009f8 --- /dev/null +++ b/Arrays/array_sum.php @@ -0,0 +1,25 @@ + "red", "b" => "green", "c" => "red", "d" => "blue", "f" => "blue"); +$result = array_unique($colors); + +echo '
';
+print_r($result);
+echo '
'; + +/** + * The output of the code above will be: + * Array + * ( + * [a] => red + * [b] => green + * [c] => blue + * ) + * + */ \ No newline at end of file diff --git a/Arrays/arsort.php b/Arrays/arsort.php new file mode 100644 index 0000000..0099936 --- /dev/null +++ b/Arrays/arsort.php @@ -0,0 +1,45 @@ + "35", + "Ben" => "37", + "Joe" => "43", +); +arsort($users); + +echo '
';
+print_r($users);
+echo '
'; + +/** + * The output of the code above will be: + * Array + * ( + * [Joe] => 43 + * [Ben] => 37 + * [Kat] => 35 + * ) + * + */ \ No newline at end of file diff --git a/Arrays/asort.php b/Arrays/asort.php new file mode 100644 index 0000000..cc4ad3b --- /dev/null +++ b/Arrays/asort.php @@ -0,0 +1,45 @@ + "35", + "Ben" => "37", + "Joe" => "43" +); +asort($users); + +echo '
';
+print_r($users);
+echo '
'; + +/** + * The output of the code above will be: + * Array + * ( + * [Kat] => 35 + * [Ben] => 37 + * [Joe] => 43 + * ) + * + */ \ No newline at end of file diff --git a/Arrays/count.php b/Arrays/count.php new file mode 100644 index 0000000..8674211 --- /dev/null +++ b/Arrays/count.php @@ -0,0 +1,29 @@ + "35", + "Ben" => "37", + "Joe" => "43" +); +krsort($users); + +echo '
';
+print_r($users);
+echo '
'; + +/** + * The output of the code above will be: + * Array + * ( + * [Kat] => 35 + * [Joe] => 43 + * [Ben] => 37 + * ) + * + */ \ No newline at end of file diff --git a/Arrays/ksort.php b/Arrays/ksort.php new file mode 100644 index 0000000..d409c5f --- /dev/null +++ b/Arrays/ksort.php @@ -0,0 +1,45 @@ + "35", + "Ben" => "37", + "Joe" => "43", +); +ksort($users); + +echo '
';
+print_r($users);
+echo '
'; + +/** + * The output of the code above will be: + * Array + * ( + * [Ben] => 37 + * [Joe] => 43 + * [Kat] => 35 + * ) + * + */ \ No newline at end of file diff --git a/Arrays/range.php b/Arrays/range.php new file mode 100644 index 0000000..cc48313 --- /dev/null +++ b/Arrays/range.php @@ -0,0 +1,36 @@ +'; +print_r($numbers); +echo ''; + +/** + * The output of the code above will be: + * Array + * ( + * [0] => 1 + * [1] => 2 + * [2] => 3 + * [3] => 4 + * [4] => 5 + * ) + * + */ \ No newline at end of file diff --git a/Arrays/reset.php b/Arrays/reset.php new file mode 100644 index 0000000..5a2d2bf --- /dev/null +++ b/Arrays/reset.php @@ -0,0 +1,40 @@ +"; +echo next($people) . "
"; +reset($people); + +/** + * The output of the code above will be: + * + * Peter + * Joe + * + */ \ No newline at end of file diff --git a/Arrays/rsort.php b/Arrays/rsort.php new file mode 100644 index 0000000..bf6f410 --- /dev/null +++ b/Arrays/rsort.php @@ -0,0 +1,46 @@ + "35", + "Ben" => "37", + "Joe" => "43" +); +rsort($users); + +echo '
';
+print_r($users);
+echo '
'; + +/** + * The output of the code above will be: + * + * Array + * ( + * [0] => 43 + * [1] => 37 + * [2] => 35 + * ) + * + */ \ No newline at end of file diff --git a/Arrays/shuffle.php b/Arrays/shuffle.php new file mode 100644 index 0000000..1e7cd37 --- /dev/null +++ b/Arrays/shuffle.php @@ -0,0 +1,39 @@ +'; +print_r($users); +echo ''; + +/** + * The output of the code above will be: + * + * Array + * ( + * [0] => yellow + * [1] => purple + * [2] => red + * [3] => blue + * [4] => green + * ) + * + * n:b: your output might be changed.. + * + */ \ No newline at end of file diff --git a/Arrays/sizeof.php b/Arrays/sizeof.php new file mode 100644 index 0000000..b4c9bb5 --- /dev/null +++ b/Arrays/sizeof.php @@ -0,0 +1,27 @@ + "35", + "Ben" => "37", + "Joe" => "43" +); +sort($users); + +echo '
';
+print_r($users);
+echo '
'; + +/** + * The output of the code above will be: + * + * Array + * ( + * [0] => 35 + * [1] => 37 + * [2] => 43 + * ) + */ \ No newline at end of file diff --git a/Basic/.gitignore b/Basic/.gitignore new file mode 100644 index 0000000..723ef36 --- /dev/null +++ b/Basic/.gitignore @@ -0,0 +1 @@ +.idea \ No newline at end of file diff --git a/Basic/array.php b/Basic/array.php new file mode 100644 index 0000000..21c1c23 --- /dev/null +++ b/Basic/array.php @@ -0,0 +1,153 @@ + value) + * + * key - Optional. Specifies the key, of type numeric + * or string. If not set, an integer key is + * generated, starting at 0. + * value - Required. Specifiee the value. + * + */ + +// Example 1: +$fruits = array( + 'a' => 'Apple', + 'b' => 'Banana', + 'c' => 'Capsicum', +); + +print_r($fruits); + +/** + * The output of the code above will be: + * Array ([a] => Apple [b] => Banana [c] => Capsicum) + */ + + + +// Example 2: +$animal = array('Dog', 'Cat', 'Horse'); + +print_r($animal); + +/** + * The output of the code above will be: + * Array ([1] => Dog [2] => Cat [3] => Horse) + */ + + + +// Example 3: +$students = array( + 'rahim' => array( + 'fullName' => 'Adbur Rahim', + 'age' => 27, + 'address' => array( + 'city' => 'Block-A, Road-12, Dhanmondi', + 'postCode' => '1435', + 'district' => 'Dhaka', + ), + ), + 'karim' => array( + 'fullName' => 'Karim Khan', + 'age' => 31, + 'address' => array( + 'city' => 'Block-C, Road-37, Rampura', + 'postCode' => '1310', + 'district' => 'Dhaka', + ), + ), + 'saleh' => array( + 'fullName' => 'Saleh Ahmed', + 'age' => 42, + 'address' => array( + 'city' => 'Block-F, Road-6, Banani', + 'postCode' => '1245', + 'district' => 'Dhaka', + ), + ), +); + +// Example 4: +$students = [ + 'rahim' => [ + 'fullName' => 'Adbur Rahim', + 'age' => 27, + 'address' => [ + 'city' => 'Block-A, Road-12, Dhanmondi', + 'postCode' => '1435', + 'district' => 'Dhaka', + ], + ], + 'karim' => [ + 'fullName' => 'Karim Khan', + 'age' => 31, + 'address' => [ + 'city' => 'Block-C, Road-37, Rampura', + 'postCode' => '1310', + 'district' => 'Dhaka', + ], + ], + 'saleh' => [ + 'fullName' => 'Saleh Ahmed', + 'age' => 42, + 'address' => [ + 'city' => 'Block-F, Road-6, Banani', + 'postCode' => '1245', + 'district' => 'Dhaka', + ], + ], +]; + +print_r($students); + +/** + * The output of the code above will be: + * + * Array + * ( + * [rahim] => Array + * ( + * [fullName] => Adbur Rahim + * [age] => 27 + * [address] => Array + * ( + * [city] => Block-A, Road-12, Dhanmondi + * [postCode] => 1435 + * [district] => Dhaka + * ) + * ) + * [karim] => Array + * ( + * [fullName] => Adbur Rahim + * [age] => 27 + * [address] => Array + * ( + * [city] => Block-A, Road-12, Dhanmondi + * [postCode] => 1435 + * [district] => Dhaka + * ) + * ) + * [saleh] => Array + * ( + * [fullName] => Saleh Ahmed + * [age] => 42 + * [address] => Array + * ( + * [city] => Block-F, Road-6, Banani + * [postCode] => 1245 + * [district] => Dhaka + * ) + * ) + * ) + * + */ diff --git a/Basic/comment.php b/Basic/comment.php new file mode 100644 index 0000000..fafbb46 --- /dev/null +++ b/Basic/comment.php @@ -0,0 +1,14 @@ +getDocComment() . PHP_EOL; \ No newline at end of file diff --git a/Basic/constants.php b/Basic/constants.php new file mode 100644 index 0000000..5a44b27 --- /dev/null +++ b/Basic/constants.php @@ -0,0 +1,46 @@ + apple + * [1] => banana + * [2] => mango + * ) + */ diff --git a/Basic/data-type.php b/Basic/data-type.php new file mode 100644 index 0000000..702293d --- /dev/null +++ b/Basic/data-type.php @@ -0,0 +1,55 @@ +'; + + +// Example 2: +function users($firstName, $lastName) +{ + echo $firstName .' '. $lastName; +} +users('John', 'Doe'); \ No newline at end of file diff --git a/Basic/hello.php b/Basic/hello.php new file mode 100644 index 0000000..e86a38e --- /dev/null +++ b/Basic/hello.php @@ -0,0 +1,65 @@ + ['abdur rahim', 30], + 'karim' => ['karim hossain', 25], + 'himel' => ['himel ahmed', 30], +); + +// Example 01: echo +echo 'John Doe'; +echo $fullName; +echo ($fullName); + + +// Example 02: print +print 'John Doe'; +print $fullName; +print($fullName); + + +// Example 03: printf() +printf($format, 'Kabir khan', 30); + + +// Example 04: print_r() +print_r($fruits); + +echo '
';
+print_r($users);
+echo '
'; + + +// Example 05: var_dump() +echo '
';
+var_dump($users);
+echo '
'; + + +// Example 06: Variables Type +echo gettype($variable); + + +// Example 07: Print Out Variables +echo "\$color = " . $color; \ No newline at end of file diff --git a/Basic/math.php b/Basic/math.php new file mode 100644 index 0000000..4a0534f --- /dev/null +++ b/Basic/math.php @@ -0,0 +1,69 @@ +"; +echo "The value of Square Root = " . sqrt(16) . "
"; +echo "The value of Absolute = " . abs(-45.154) . "
"; +echo "The value of Ceil = " . ceil(45.154) . "
"; +echo "The value of Round = " . round(45.154) . "
"; +echo "The value of Pow = " . pow(12, 2) . "
"; diff --git a/Basic/operators.php b/Basic/operators.php new file mode 100644 index 0000000..5916df3 --- /dev/null +++ b/Basic/operators.php @@ -0,0 +1,85 @@ + $y; // (Greater than) +$x < $y; // (Less than) +$x >= $y; // (Greater than or equal to) +$x <= $y; // (Less than or equal to) +$x <=> $y; // (Spaceship) + + +// Example 04: Increment/Decrement operators +++$x; // Pre-increment +$x++; // Post-increment +--$x; // Pre-decrement +$x--; // Post-decrement + + +// Example 05: Logical operators +$x and $y; // (And) True if both $x and $y are true +$x && $y; // (And) True if both $x and $y are true +$x or $y; // (Or) True if either $x or $y is true +$x || $y; // (Or) True if either $x or $y is true +$x xor $y; // (Xor) True if either $x or $y is true, but not both +!$x; // (Not) True if $x is not true + + +// Example 06: String operators +$userName = 'John'; // Concatenation +$userName .= ' Doe'; // Concatenation assignment + + +// Example 07: Array operators +$x + $y; // (Union) Union of $x and $y +$x == $y; // (Equality) Returns true if $x and $y have the same key/value pairs +$x === $y; // (Identity) Returns true if $x and $y have the same key/value pairs in the same order and of the same types +$x != $y; // (Inequality) Returns true if $x is not equal to $y +$x != $y; // (Inequality) Returns true if $x is not equal to $y +$x !== $y; // (Non-identity) Returns true if $x is not identical to $y + + +// Example 08: Conditional Assignment operators +$result = $x ? $x : $y; // (Ternary) +$result = $x ?? $x; // (Null coalescing) \ No newline at end of file diff --git a/Basic/quotations.php b/Basic/quotations.php new file mode 100644 index 0000000..9e92ce3 --- /dev/null +++ b/Basic/quotations.php @@ -0,0 +1,13 @@ +'; +echo rand(1, 999); \ No newline at end of file diff --git a/Basic/strings.php b/Basic/strings.php new file mode 100644 index 0000000..bee3338 --- /dev/null +++ b/Basic/strings.php @@ -0,0 +1,21 @@ +'; +echo str_word_count($userName); +echo '
'; +echo strpos($userName, 'Khan'); \ No newline at end of file diff --git a/Basic/variables.php b/Basic/variables.php new file mode 100644 index 0000000..c6857bd --- /dev/null +++ b/Basic/variables.php @@ -0,0 +1,22 @@ + 1) { + $fileNames = $argv[2]; + $resources = '$id'; + $directory = ucwords(str_replace('make:', '', $argv[1])) . 's'; + $filesData = null; + + if ($argv[1] === "make:model") { + $filesData = <<getMessage()); +} \ No newline at end of file diff --git a/Control Flow/.gitignore b/Control Flow/.gitignore new file mode 100644 index 0000000..723ef36 --- /dev/null +++ b/Control Flow/.gitignore @@ -0,0 +1 @@ +.idea \ No newline at end of file diff --git a/Control Flow/README.md b/Control Flow/README.md new file mode 100644 index 0000000..e69de29 diff --git a/Control Flow/continue-break.php b/Control Flow/continue-break.php new file mode 100644 index 0000000..dd74826 --- /dev/null +++ b/Control Flow/continue-break.php @@ -0,0 +1 @@ +continue-break.php \ No newline at end of file diff --git a/Control Flow/if-else.php b/Control Flow/if-else.php new file mode 100644 index 0000000..ba45a2a --- /dev/null +++ b/Control Flow/if-else.php @@ -0,0 +1,21 @@ + setcookie(name, value, expire, path, domain, secure, httponly); +get => $_COOKIE['cookie_name']; +delete => setcookie("cookie_name", "", time() - 3600); \ No newline at end of file diff --git a/Cookies/index.php b/Cookies/index.php new file mode 100644 index 0000000..4675f5c --- /dev/null +++ b/Cookies/index.php @@ -0,0 +1,84 @@ + + + + + + + <?php echo 'Learn PHP ' . str_replace('.19', '+', phpversion()); ?> + + + + + + + + +
+
PHP Cookies
+
+
+ +
+
+

Cookies Information

+ Hurrah! Cookies is set already
'; + else : + echo '
Congratulation! Cookies is set successfully
'; + endif; + elseif ($_GET['url'] === 'get') : + + //Get Cookies + if (isset($_COOKIE['name'])) : + echo '
    '; + echo '
  • + Name: '. $_COOKIE['name'] .' +
  • '; + echo '
  • + Email: '. $_COOKIE['email'] .' +
  • '; + echo '
  • + Address: '. $_COOKIE['address'] .' +
  • '; + echo '
'; + else : + echo '
Oops! Cookies is not set yet
'; + endif; + elseif ($_GET['url'] === 'delete') : + + //Delete Cookies + if (isset($_COOKIE['name'])) : + setcookie('name', '', time(), '/', false, false); + setcookie('email', '', time(), '/', false, false); + setcookie('address', '', time(), '/', false, false); + endif; + + if (!empty($_COOKIE['name'])) : + echo '
Congratulation! cookies is delete successfully
'; + else : + echo '
Oops! Cookies is alreday deleted
'; + endif; + endif; + ?> +
+
+
+ + + \ No newline at end of file diff --git a/Design Pattern/.gitignore b/Design Pattern/.gitignore new file mode 100644 index 0000000..723ef36 --- /dev/null +++ b/Design Pattern/.gitignore @@ -0,0 +1 @@ +.idea \ No newline at end of file diff --git a/Design Pattern/Creational/Abstract.php b/Design Pattern/Creational/Abstract.php new file mode 100644 index 0000000..9041e84 --- /dev/null +++ b/Design Pattern/Creational/Abstract.php @@ -0,0 +1,104 @@ +assertInstanceOf(JsonWriter::class, $writerFactory->createJsonWriter()); + $this->assertInstanceOf(CsvWriter::class, $writerFactory->createCsvWriter()); + } +} \ No newline at end of file diff --git a/Encryption/.gitignore b/Encryption/.gitignore new file mode 100644 index 0000000..723ef36 --- /dev/null +++ b/Encryption/.gitignore @@ -0,0 +1 @@ +.idea \ No newline at end of file diff --git a/Encryption/base64.php b/Encryption/base64.php new file mode 100644 index 0000000..30a2604 --- /dev/null +++ b/Encryption/base64.php @@ -0,0 +1,31 @@ +'; +echo $decode . '
'; + +# Output (encode) => VGhpcyBzdHJpbmcgaXMgZW5jb2RlZCB1c2luZyBiYXNlNDYgZW5jb2RlIGZ1bmN0aW9u +# Output (decode) => This string is encoded using base46 encode function diff --git a/Encryption/bin_hex.php b/Encryption/bin_hex.php new file mode 100644 index 0000000..4c9892a --- /dev/null +++ b/Encryption/bin_hex.php @@ -0,0 +1,30 @@ +"; +echo $bin; + +# Output (encode) => 42696e61727920746f2048657861646963696d616c2056616c7565 +# Output (decode) => Binary to Hexadicimal Value \ No newline at end of file diff --git a/Encryption/hash.php b/Encryption/hash.php new file mode 100644 index 0000000..f116cac --- /dev/null +++ b/Encryption/hash.php @@ -0,0 +1,23 @@ +"; +echo sha1($password); // 160-bit + +# Output (md5) => d6b0ab7f1c8ab8f514db9a6d85de160a +# Output (sha1) => 701b389b848a2b1cfab867093101d8d5ac56addd \ No newline at end of file diff --git a/Encryption/salt.php b/Encryption/salt.php new file mode 100644 index 0000000..501e22a --- /dev/null +++ b/Encryption/salt.php @@ -0,0 +1,18 @@ + MTIzQHBhc3MyZTAwOTk2MTE1M2Y0YmY5NGQ2YjY0OTgyMjAzNmJiZQ== \ No newline at end of file diff --git a/Encryption/string.php b/Encryption/string.php new file mode 100644 index 0000000..cfa4a78 --- /dev/null +++ b/Encryption/string.php @@ -0,0 +1,31 @@ +
"; +echo $decode; + +# Output (encode) => <;&EF92!I life is all about next steps diff --git a/Exceptions/.gitignore b/Exceptions/.gitignore new file mode 100644 index 0000000..e69de29 diff --git a/Exceptions/ErrorHandler.php b/Exceptions/ErrorHandler.php new file mode 100644 index 0000000..a8b59c8 --- /dev/null +++ b/Exceptions/ErrorHandler.php @@ -0,0 +1,20 @@ +getMessage() . ' at line no ' . $this->getLine(); + } + + public function errorDetails() + { + return [ + 'error' => $this->getMessage(), + 'file' => $this->getFile(), + 'line' => $this->getLine(), + 'code' => $this->getCode() + ]; + } +} diff --git a/Exceptions/PDOException.php b/Exceptions/PDOException.php new file mode 100644 index 0000000..9231bbe --- /dev/null +++ b/Exceptions/PDOException.php @@ -0,0 +1,35 @@ +prepare($sqlCode); + $queries->execute(); + $isError = $queries->errorInfo(); + if (is_array($isError) && !empty($isError[1])) { + $datalist = [ + 'code' => $queries->errorCode(), + 'type' => $isError[1], + 'info' => $isError[2], + ]; + } else { + $datalist = $queries->fetchAll(PDO::FETCH_ASSOC); + } + + print_r($datalist); + } else { + throw new PDOException('Oops! Unable to connect ' . $dbName . ' database'); + } +} catch (PDOException $e) { + print_r(ucfirst($e->getMessage())); +} diff --git a/Exceptions/README.md b/Exceptions/README.md new file mode 100644 index 0000000..6478c85 --- /dev/null +++ b/Exceptions/README.md @@ -0,0 +1,7 @@ +## Exception Handling + + +- getMessage() +- getLine() +- getCode() +- getFile() diff --git a/Exceptions/TryCatch.php b/Exceptions/TryCatch.php new file mode 100644 index 0000000..d9dd2ee --- /dev/null +++ b/Exceptions/TryCatch.php @@ -0,0 +1,78 @@ + $netCash, 'percent' => $percent . '%', 'balance' => $netCash + ($netCash * ($percent / 100))]); + } +} catch (Exception $e) { + print_r($e->getMessage()); +} + + + + +// TODO: Exception Handling Using Functional Block +function interestCalculate($balance, $interest) +{ + try { + if ($balance <= 0) { + throw new Exception('Oops! Not enough balance to your account' . PHP_EOL); + } elseif ($interest <= 0) { + throw new Exception('Oops! Interest rate should be more 0' . PHP_EOL); + } else { + print_r(['balance' => $balance, 'percent' => $interest . '%', 'totalPay' => $balance + ($balance * ($interest / 100))]); + } + } catch (Exception $e) { + print_r($e->getMessage()); + } +} + +interestCalculate(742, 4); + + + + +// TODO: Custom Exception Handling +$userName = 'Kabir Khan'; +$password = 'abc123'; + +try { + if (empty($userName) && empty($password)) { + throw new ErrorHandler('Oops! user name and password is required'); + } elseif (strlen($password) <= 0) { + throw new ErrorHandler('Oops! password length should be more that 0'); + } else { + print_r(['user_name' => $userName, 'password' => $password]); + } +} catch (ErrorHandler $e) { + print_r($e->getError() . PHP_EOL); +} + + + + +// TODO: Custom Exception Handling Using Functional Block +function userDetails($args) +{ + try { + if (empty($args) && !is_array($args)) { + throw new ErrorHandler('User information should be passed by an array'); + } elseif (is_array($args) && (count($args) === 1)) { + throw new ErrorHandler('User information must be more descriptive'); + } else { + print_r($args); + } + } catch (ErrorHandler $e) { + print_r($e->errorDetails()); + } +} + +userDetails(''); diff --git a/Exceptions/TryCatchFinally.php b/Exceptions/TryCatchFinally.php new file mode 100644 index 0000000..bec6b88 --- /dev/null +++ b/Exceptions/TryCatchFinally.php @@ -0,0 +1,36 @@ + 0 && $increment === true) { + $totalSalary = [ + 'basic_salary' => $basicSalary, + 'provident_fund' => $basicSalary * 0.10, + 'travel_allowance' => $basicSalary * 0.08, + 'dinning_allowance' => $basicSalary * 0.15, + 'yearly_increment' => $basicSalary * 0.05, + 'total_salary' => $basicSalary + ($basicSalary * 0.10) + ($basicSalary * 0.08) + ($basicSalary * 0.15) + ($basicSalary * 0.05) + ]; + } elseif ($basicSalary > 0 && $increment === false) { + $totalSalary = [ + 'basic_salary' => $basicSalary, + 'provident_fund' => $basicSalary * 0.10, + 'travel_allowance' => $basicSalary * 0.08, + 'dinning_allowance' => $basicSalary * 0.15, + 'yearly_increment' => 0, + 'total_salary' => $basicSalary + ($basicSalary * 0.10) + ($basicSalary * 0.08) + ($basicSalary * 0.15) + ]; + } else { + throw new Exception('Oops! Employees basic salary must not be nil'); + } +} catch (Exception $e) { + print_r($e->getMessage()); +} finally { + if (!is_null($basicSalary) && $basicSalary > 0) { + print_r($totalSalary); + } +} diff --git a/File Handling/.gitignore b/File Handling/.gitignore new file mode 100644 index 0000000..723ef36 --- /dev/null +++ b/File Handling/.gitignore @@ -0,0 +1 @@ +.idea \ No newline at end of file diff --git a/File Handling/copy.php b/File Handling/copy.php new file mode 100644 index 0000000..e69de29 diff --git a/File Handling/create.php b/File Handling/create.php new file mode 100644 index 0000000..e69de29 diff --git a/File Handling/delete.php b/File Handling/delete.php new file mode 100644 index 0000000..e69de29 diff --git a/File Handling/directory.php b/File Handling/directory.php new file mode 100644 index 0000000..e69de29 diff --git a/File Handling/open.php b/File Handling/open.php new file mode 100644 index 0000000..e69de29 diff --git a/File Handling/path.php b/File Handling/path.php new file mode 100644 index 0000000..e69de29 diff --git a/File Handling/read.php b/File Handling/read.php new file mode 100644 index 0000000..e69de29 diff --git a/File Handling/write.php b/File Handling/write.php new file mode 100644 index 0000000..e69de29 diff --git a/Form Handling/.gitignore b/Form Handling/.gitignore new file mode 100644 index 0000000..723ef36 --- /dev/null +++ b/Form Handling/.gitignore @@ -0,0 +1 @@ +.idea \ No newline at end of file diff --git a/Form Handling/file.php b/Form Handling/file.php new file mode 100644 index 0000000..5ba4319 --- /dev/null +++ b/Form Handling/file.php @@ -0,0 +1,60 @@ + + + + + + <?php echo 'Learn PHP ' . str_replace('.19', '+', phpversion()); ?> + + + + + + + + +
+
+
+
+
+
FILES Method in PHP
+
+
+
+
+
+
+ + +
+
+ +
+
+
+
+
+
+ '; + print_r($_FILES); + echo ''; + + move_uploaded_file($_FILES['file']['tmp_name'], 'uploads/' . $_FILES['file']['name']); + + echo '

File uploaded successfully

'; + else : + echo '

please submit this above form...

'; + endif; + ?> +
+
+
+
+
+ + + \ No newline at end of file diff --git a/Form Handling/get.php b/Form Handling/get.php new file mode 100644 index 0000000..8bfbf0e --- /dev/null +++ b/Form Handling/get.php @@ -0,0 +1,96 @@ + + + + + + <?php echo 'Learn PHP ' . str_replace('.19', '+', phpversion()); ?> + + + + + + + + +
+
+
+
+
+
GET Method in PHP
+
+
+
+
+
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+
+ + +
+
+
+ +
+
+
+
+
+
+ '; + print_r($_GET); + echo ''; + else : + echo '

please submit this above form...

'; + endif; + ?> +
+
+
+
+
+ + + \ No newline at end of file diff --git a/Form Handling/post.php b/Form Handling/post.php new file mode 100644 index 0000000..55e6f09 --- /dev/null +++ b/Form Handling/post.php @@ -0,0 +1,96 @@ + + + + + + <?php echo 'Learn PHP ' . str_replace('.19', '+', phpversion()); ?> + + + + + + + + +
+
+
+
+
+
POST Method in PHP
+
+
+
+
+
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+
+ + +
+
+
+ +
+
+
+
+
+
+ '; + print_r($_POST); + echo ''; + else : + echo '

please submit this above form...

'; + endif; + ?> +
+
+
+
+
+ + + diff --git a/Form Handling/request.php b/Form Handling/request.php new file mode 100644 index 0000000..d5178bf --- /dev/null +++ b/Form Handling/request.php @@ -0,0 +1,102 @@ + + + + + + <?php echo 'Learn PHP ' . str_replace('.19', '+', phpversion()); ?> + + + + + + + + +
+
+
+
+
+
REQUEST Method in PHP
+
+
+
+
+
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+
+ + +
+
+
+ +
+
+
+
+
+
+ This is a post method

'; + echo '
';
+							print_r($_POST);
+							echo '
'; + elseif ($_SERVER['REQUEST_METHOD'] === 'GET' && isset($_GET['addPost'])) : + echo '

This is a get method

'; + echo '
';
+							print_r($_GET);
+							echo '
'; + else : + echo '

please submit this above form...

'; + endif; + ?> +
+
+
+
+
+ + + \ No newline at end of file diff --git a/Functions/.gitignore b/Functions/.gitignore new file mode 100644 index 0000000..723ef36 --- /dev/null +++ b/Functions/.gitignore @@ -0,0 +1 @@ +.idea \ No newline at end of file diff --git a/Functions/Anonymous.php b/Functions/Anonymous.php new file mode 100644 index 0000000..b3d9bbc --- /dev/null +++ b/Functions/Anonymous.php @@ -0,0 +1 @@ + ' . argVal($string); + + +function statement(&$stmt): string +{ + return $stmt = 'call by reference' . PHP_EOL; +} + +$states = 'This function is '; +echo statement($states); diff --git a/Functions/Arrow.php b/Functions/Arrow.php new file mode 100644 index 0000000..0535ffe --- /dev/null +++ b/Functions/Arrow.php @@ -0,0 +1,47 @@ + $arg, + 'total' => $count + ]; + }, array_unique($split), array_count_values($split)); +} + +print_r(stringValues('programming is all about copy and paste')); + + + + + +// TODO: Example of Remove White Space Using Arrow Function +$removeSpace = fn(string $arg) => (strpos($arg, ' ')) ? str_replace(' ', '', $arg) : $arg; +echo $removeSpace('say hello world') . PHP_EOL; + + + + + +// TODO: Example of Extract A String With Total Usage Using Arrow Function +$charsValues = fn(string $str) => array_map(fn($chars, $total) => compact('chars', 'total'), array_unique(str_split($removeSpace($str))), array_count_values(str_split($removeSpace($str)))); +print_r($charsValues('programming is all about copy and paste')); diff --git a/Functions/Closure.php b/Functions/Closure.php new file mode 100644 index 0000000..7722fe1 --- /dev/null +++ b/Functions/Closure.php @@ -0,0 +1,86 @@ + strtoupper($string), + 'lower' => $string, + 'camel' => str_replace(' ', '', lcfirst(ucwords($string))), + 'kebab' => str_replace(' ', '-', $string), + 'snake' => str_replace(' ', '_', $string), + 'pascal' => str_replace(' ', '', ucwords($string)) + ); +} + +echo convertCase('product Controller')['snake'] . PHP_EOL; + + + + + +// TODO: Example of Request Parsing Using Legacy Function Statement +function parseURL($request, $response): array +{ + return [ + $request => is_array($response) ? array_map(function ($res) { + return $res; + }, $response) : $response + ]; +} + +print_r(parseURL('GET', ['name' => 'Kabir Khan', 'email' => 'kabirkhan@gmail.com'])); +print_r(parseURL('POST', 'Get all the users information')); + + + + + +// TODO: Example of Convert Case Using CallBack or Closure Function Statement +function convertString($sentence, $callback) +{ + $string = strtolower($sentence); + $result = array( + 'upper' => strtoupper($string), + 'lower' => $string, + 'camel' => str_replace(' ', '', lcfirst(ucwords($string))), + 'kebab' => str_replace(' ', '-', $string), + 'snake' => str_replace(' ', '_', $string), + 'pascal' => str_replace(' ', '', ucwords($string)) + ); + + if (is_callable($callback)) { + call_user_func($callback, $result); + } +} + +convertString('product Controller', function ($string) { + echo $string['camel'] . PHP_EOL; +}); + + + + + +// TODO: Example of Request Parsing Using CallBack or Closure Function Statement +function route($request, $response, $callback): array +{ + $result = array( + $request => $response + ); + + if (is_callable($callback)) { + call_user_func($callback, $result); + } + + return $result; +} + +route('GET', ['name' => 'Kabir Khan', 'email' => 'kabirkhan@gmail.com'], function ($arr) { + print_r($arr); +}); + +route('POST', 'Get all the users information', function ($data) { + print_r($data); +}); diff --git a/Functions/Declaration.php b/Functions/Declaration.php new file mode 100644 index 0000000..b3d9bbc --- /dev/null +++ b/Functions/Declaration.php @@ -0,0 +1 @@ + (Function Statement) + +function sayHello() { + return 'this is an statement of a function'; +} +``` + +```php +[comment] <> (Function Expression) + +function() { + return 'this is an expression of a function'; +}; +``` +
+ + +- `is_callable` Verify that a value can be called as a function from the current scope. +- `call_user_func` Call the callback given by the first parameter + +
+ +- [Closure Function](Closure.php) +```bash +$ php Closure.php +``` +- [Arrow Function](Arrow.php) +```bash +$ php Arrow.php +``` +- [Variable Scope](Scope.php) +```bash +$ php Scope.php +``` diff --git a/Functions/Recursive.php b/Functions/Recursive.php new file mode 100644 index 0000000..f5fca9e --- /dev/null +++ b/Functions/Recursive.php @@ -0,0 +1,109 @@ + 0) { +// echo $arr[$length - 1] . PHP_EOL; +// $length--; +// if ($length === 0) { +// exit(); +// } +// printArray($arr, $length); +// } +//} +// +//printArray($fruits); + + +$fruits = ['Kabir Khan', 'kabir.khan@gmail.com', '+880 1316-440504', 'Software Developer', 'ABC International Company Limited']; +function printArray($arr, $length = 0, $len = 0) +{ + if ($length === 0) { + $length = count($arr); + } + + $size = count($arr); + if (($len < $size) && ($length > 0)) { + echo $arr[$len] . PHP_EOL; + $length--; + $len++; + if (($length === 0) && ($len = $size)) { + exit(); + } + printArray($arr, $length, $len); + } +} +printArray($fruits); + + + + +// TODO: Example of Fibonacci Recursion +//function Fibonacci($number) +//{ +// if ($number == 0) { +// return 0; +// } else if ($number == 1) { +// return 1; +// } else { +// return (Fibonacci($number - 1) + Fibonacci($number - 2)); +// } +//} +// +// +//$number = 10; +//for ($counter = 0; $counter < $number; $counter++) { +// echo Fibonacci($counter), ' '; +//} + + +function Fibonacci($number, $a = 0, $b = 1) +{ + if ($number != 0) { + echo !empty($a) ? " " . $a : 0; + $summation = (!empty($a) ? $a : 0) + (!empty($b) ? $b : 1); + $a = (!empty($b) ? $b : 1); + $b = (!empty($summation) ? $summation : 0); + $number--; + Fibonacci($number, $a, $b); + } +} + +//Fibonacci(20); diff --git a/Functions/Scope.php b/Functions/Scope.php new file mode 100644 index 0000000..c0e96bf --- /dev/null +++ b/Functions/Scope.php @@ -0,0 +1,43 @@ + 'Total value is = $' . $qty * $price . PHP_EOL; + +echo $getPrice(30); + + + + + +// TODO: Example of Variable Scope Using Global Statement +function sellingPrice($qty): string { + global $price; + return 'Total value is = $' . $qty * $price . PHP_EOL; +} + +echo sellingPrice(40); diff --git a/Iteration/.gitignore b/Iteration/.gitignore new file mode 100644 index 0000000..723ef36 --- /dev/null +++ b/Iteration/.gitignore @@ -0,0 +1 @@ +.idea \ No newline at end of file diff --git a/Iteration/README.md b/Iteration/README.md new file mode 100644 index 0000000..e69de29 diff --git a/Iteration/do-while.php b/Iteration/do-while.php new file mode 100644 index 0000000..af807a8 --- /dev/null +++ b/Iteration/do-while.php @@ -0,0 +1,44 @@ +"; + $i++; +} while ($i <= 10); + + + +$users = array( + array( + 'name' => 'Kabir Khan', + 'email' => 'kabir.khan@gmail.com', + 'mobile' => '+880 1647-754123' + ), + array( + 'name' => 'Zaber Muhammad', + 'email' => 'zaber.muhammad@gmail.com', + 'mobile' => '+880 1451-845232' + ), + array( + 'name' => 'Rahim Hossain', + 'email' => 'hossain.rahim@gmail.com', + 'mobile' => '+880 01745-453362' + ) +); + + +$n = 0; +do { + echo '
';
+	print_r($users[$n]);
+	echo '
'; + $n++; +} while ($n < count($users)); diff --git a/Iteration/for.php b/Iteration/for.php new file mode 100644 index 0000000..31dce1f --- /dev/null +++ b/Iteration/for.php @@ -0,0 +1,32 @@ + 'Kabir Khan', + 'email' => 'kabir.khan@gmail.com', + 'mobile' => '+880 1647-754123' + ), + array( + 'name' => 'Zaber Muhammad', + 'email' => 'zaber.muhammad@gmail.com', + 'mobile' => '+880 1451-845232' + ), + array( + 'name' => 'Rahim Hossain', + 'email' => 'hossain.rahim@gmail.com', + 'mobile' => '+880 01745-453362' + ) +); + + +for ($n = 0; $n < count($users); $n++) : + echo '
'; 
+	print_r($users[$n]);
+	echo '
'; +endfor; \ No newline at end of file diff --git a/Iteration/foreach.php b/Iteration/foreach.php new file mode 100644 index 0000000..9eb79ec --- /dev/null +++ b/Iteration/foreach.php @@ -0,0 +1,33 @@ + 'Kabir Khan', + 'email' => 'kabir.khan@gmail.com', + 'mobile' => '+880 1647-754123' + ), + array( + 'name' => 'Zaber Muhammad', + 'email' => 'zaber.muhammad@gmail.com', + 'mobile' => '+880 1451-845232' + ), + array( + 'name' => 'Rahim Hossain', + 'email' => 'hossain.rahim@gmail.com', + 'mobile' => '+880 01745-453362' + ) +); + + +// foreach ($users as $user) { +// echo '
'; 
+// 	// print_r($n);
+// 	print_r($user);
+// 	echo '
'; +// }; + +foreach ($users as $user) : + echo '
'; 	
+	print_r($user);
+	echo '
'; +endforeach; \ No newline at end of file diff --git a/Iteration/while.php b/Iteration/while.php new file mode 100644 index 0000000..8365bda --- /dev/null +++ b/Iteration/while.php @@ -0,0 +1,41 @@ +"; + $i++; +} + + +$users = array( + array( + 'name' => 'Kabir Khan', + 'email' => 'kabir.khan@gmail.com', + 'mobile' => '+880 1647-754123' + ), + array( + 'name' => 'Zaber Muhammad', + 'email' => 'zaber.muhammad@gmail.com', + 'mobile' => '+880 1451-845232' + ), + array( + 'name' => 'Rahim Hossain', + 'email' => 'hossain.rahim@gmail.com', + 'mobile' => '+880 01745-453362' + ) +); + +$n = 0; +while ($n < count($users)) { + echo '
';
+	print_r($users[$n]);
+	echo '
'; + $n++; +} diff --git a/JSON/README.md b/JSON/README.md new file mode 100644 index 0000000..e69de29 diff --git a/JSON/app/Controllers/JsonCrudController.php b/JSON/app/Controllers/JsonCrudController.php new file mode 100644 index 0000000..551ebd2 --- /dev/null +++ b/JSON/app/Controllers/JsonCrudController.php @@ -0,0 +1,117 @@ +fileName)) { + return json_decode(file_get_contents('app/Models/' . $this->fileName, true)); + } else { + fopen('app/Models/' . $this->fileName, 'w+'); + throw new Exception('Congratulation! ' . $this->fileName . ' is created successfully'); + } + } catch (Exception $e) { +// return $e->getMessage(); + return false; + } + } + + + /** + * Fetch All Records + * + * @return mixed|string + */ + public function all() + { + return $this->dataModel(); + } + + + /** + * Fetch A Single Record + * + * @param void + * @return void + */ + public function find($id) + { + // TODO: Implement find() method + } + + + /** + * Create A New Data + * + * @param $name + * @param $email + * @param $mobile + * @param $age + * @param $gender + * @param $profession + * @param $agree + * @return bool + */ + public function create($name, $email, $mobile, $age, $gender, $profession, $agree): bool + { + $dataSet = array( + 'fullName' => trim(addslashes($name)), + 'email' => trim(addslashes($email)), + 'mobile' => trim(addslashes($mobile)), + 'age' => trim(addslashes($age)), + 'gender' => !empty($gender) ? $gender : 'Male', + 'profession' => trim(addslashes($profession)), + 'agree' => !empty($agree) ? $agree : 'No', + 'created' => date('D j M Y') + ); + + if (file_put_contents('app/Models/' . $this->fileName, json_encode($dataSet), FILE_APPEND)) { + return true; + } else { + return false; + } + } + + + /** + * Edit An Existing Data + * + * @param int + * @return void + */ + public function edit($id) + { + // TODO: Implement edit() method + } + + + /** + * Update An Existing Data + * + * @param int + * @return void + */ + public function update($id) + { + // TODO: Implement update() method + } + + + /** + * Delete An Existing Data + * + * @param int + * @return void + */ + public function delete($id) + { + // TODO: Implement delete() method + } +} diff --git a/JSON/app/Models/users.json b/JSON/app/Models/users.json new file mode 100644 index 0000000..53991fd --- /dev/null +++ b/JSON/app/Models/users.json @@ -0,0 +1,32 @@ +[ + { + "fullName": "wuboruravi@mailinator.com", + "email": "pizyxefe@mailinator.com", + "mobile": "+1 (852) 731-7647", + "age": "36", + "gender": "Female", + "profession": "wafa@mailinator.com", + "agree": "Yes", + "created": "Thu 8 Jul 2021" + }, + { + "fullName": "tikafeki@mailinator.com", + "email": "gozyzuqu@mailinator.com", + "mobile": "+1 (966) 452-3065", + "age": "79", + "gender": "Female", + "profession": "luvogi@mailinator.com", + "agree": "Yes", + "created": "Thu 8 Jul 2021" + }, + { + "fullName": "zakevu@mailinator.com", + "email": "cydat@mailinator.com", + "mobile": "+1 (204) 132-5256", + "age": "12", + "gender": "Male", + "profession": "xyrexegumi@mailinator.com", + "agree": "Yes", + "created": "Thu 8 Jul 2021" + } +] diff --git a/JSON/index.php b/JSON/index.php new file mode 100644 index 0000000..63d66de --- /dev/null +++ b/JSON/index.php @@ -0,0 +1,206 @@ +create($_POST['name'], $_POST['email'], $_POST['mobile'], $_POST['age'], $_POST['gender'], $_POST['profession'], $_POST['agree']); + if ($result) { + $isSuccess = 1; + } else { + $isSuccess = 0; + } +} + +$users = $ctrl->all(); +// +//echo '
';
+//print_r($users);
+//echo '
'; + +?> + + + + + + + + + + + + + JSON Crud in PHP + + + +
+
+
+
JSON Crud Operation in PHP
+
+
+
+
+
+
+
Create User Data
+
+
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ +
+ + +
+
+ + +
+
+
+ + +
+
+ + +
+ +
+
+
+
+
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
#Full NameMobileEmailAgeGenderProfessionAction
1MarkOttoOttoOttoOttoOtto + + +
1MarkOttoOttoOttoOttoOtto + + +
+
+
+
+
+ +
+ + + + + + + + + + + + + + diff --git a/OOP/.gitignore b/OOP/.gitignore new file mode 100644 index 0000000..723ef36 --- /dev/null +++ b/OOP/.gitignore @@ -0,0 +1 @@ +.idea \ No newline at end of file diff --git a/OOP/Abstract/AbstractClass.php b/OOP/Abstract/AbstractClass.php new file mode 100644 index 0000000..e9c8752 --- /dev/null +++ b/OOP/Abstract/AbstractClass.php @@ -0,0 +1,6 @@ + Abstract classes are the classes in which at least one method is abstract. Unlike C++ abstract classes in PHP are declared with the help of abstract keyword. Use of abstract classes are that all base classes implementing this class should give implementation of abstract methods declared in parent class. An abstract class can contain abstract as well as non-abstract methods. + +### Usages: +- [x] An abstract class or method is defined with the ```abstract``` keyword. +- [x] An abstract class is a class that contains at least one abstract method. +- [x] An abstract method is a method that is declared, but not implemented in the code. + +### Rules for Child or Derived Class: +- [x] The child class method must be defined with the same name, and it redeclare the parent abstract method +- [x] The child class method must be defined with the same or less restricted access modifier +- [x] The number of required arguments must be the same. However, the child class may have optional arguments in addition + +### Abstract vs. Interfaces: +| Interface | Abstract | +| -------------------------------------------------------------------------------------| ----------------------------------------------------------------------------| +| Interface support multiple inheritance | Abstract class does not support multiple inheritance | +| Interface doesn't contains data member or properties | Abstract class contains data member or properties | +| Interface doesn't contains constructors | Abstract class contains constructor | +| An interface contains only incomplete member (signature of member) | An Abstract class contains both complete ```abstract``` and complete member | +| An interface cannot have access modifier by default, everything is assumed as public | An Abstract class can contains access modifier such as public and protected | +| Member of interface cannot be static | Only complete member of abstract class can be static | + +### Example No 01: + +```bash +$ php Students.php +``` + +```php +Array +( + [first_name] => Md. Rahim + [last_name] => Uddin + [age] => 30 + [email] => rahim@gmail.com + [mobile] => +88 01316-440504 + [designation] => Technical Operator + [organization] => ABC International Limited + [location] => Dhaka-1206, Bangladesh + [street] => Pathapath-1206 + [city] => Dhaka + [country] => Bangladesh +) +``` diff --git a/OOP/Abstract/Students.php b/OOP/Abstract/Students.php new file mode 100644 index 0000000..066da87 --- /dev/null +++ b/OOP/Abstract/Students.php @@ -0,0 +1,25 @@ +information('Jhon Doe', 'jhondoe@gmail.com', '+88 01645-770422', 'Dhaka-1206, Bangladesh')); +//print_r($admission->information('Kabir Khan', 'kabirkhan@gmail.com', '+88 01785-654512', 'Dhaka-1206, Bangladesh')); +//print_r($admission->classRoutine('Class One', 'English', date('h:i a'), date('h:i a', strtotime('+44 minutes')))); +//print_r($admission->classRoutine('Class Two', 'Social Science', date('h:i a', strtotime('+45 minutes')), date('h:i a', strtotime('+89 minutes')))); + + diff --git a/OOP/AccessModifier/PrivateModifier.php b/OOP/AccessModifier/PrivateModifier.php new file mode 100644 index 0000000..a7065f8 --- /dev/null +++ b/OOP/AccessModifier/PrivateModifier.php @@ -0,0 +1,22 @@ +firstName = $fName; + $this->lastName = $lName; + + echo $this->getUserName(); + } + + private function getUserName(): string + { + return $this->firstName .' '. $this->lastName . PHP_EOL; + } +} + +$user = new PrivateModifier('Md. Kabir', 'Khan'); diff --git a/OOP/AccessModifier/ProtectedModifier.php b/OOP/AccessModifier/ProtectedModifier.php new file mode 100644 index 0000000..a117cd0 --- /dev/null +++ b/OOP/AccessModifier/ProtectedModifier.php @@ -0,0 +1,31 @@ +firstName = $fName; + $this->lastName = $lName; + } + + protected function getUserName() + { + echo $this->firstName .' '. $this->lastName . PHP_EOL; + } +} + + +class ChildProtectedModifier extends ProtectedModifier +{ + public function getUserName() + { + echo $this->firstName .' '. $this->lastName . PHP_EOL; + } +} + +$user = new ChildProtectedModifier('Md. Kabir', 'Khan'); +$user->getUserName(); + diff --git a/OOP/AccessModifier/PublicModifier.php b/OOP/AccessModifier/PublicModifier.php new file mode 100644 index 0000000..f581c9a --- /dev/null +++ b/OOP/AccessModifier/PublicModifier.php @@ -0,0 +1,21 @@ +firstName = $fName; + $this->lastName = $lName; + } + + public function getUserName() + { + echo $this->firstName .' '. $this->lastName . PHP_EOL; + } +} + +$user = new PublicModifier('Md. Kabir', 'Khan'); +$user->getUserName(); diff --git a/OOP/AccessModifier/README.md b/OOP/AccessModifier/README.md new file mode 100644 index 0000000..c39be2c --- /dev/null +++ b/OOP/AccessModifier/README.md @@ -0,0 +1,44 @@ +### What is Access Modifier? +In the PHP each and every property of a class in must have one of three visibility levels, known as public, private, and protected. + +- `Public:` Public properties can be accessed by any code, whether that code is inside or outside the class. If a property is declared public, its value can be read or changed from anywhere in your script. +- `Private:` Private properties of a class can be accessed only by code inside the class. So if we create a property that’s declared private, only methods and objects inside the same class can access its contents. +- `Protected:` Protected class properties are a bit like private properties in that they can’t be accessed by code outside the class, but there’s one little difference in any class that inherits from the class i.e., base class can also access the properties. + +### Usages and Restriction: +| Modifier | Class Itself | Derived or Child Class | Outside of Class | +| ----------| :-----------------------------------: | :-----------------------------------: | :-----------------------------------: | +| Public | YES | YES | YES | +| Protected | YES | YES | NO | +| Private | YES | NO | NO | + +
+ +#### [Example for Public Access Modifier:](PublicModifier.php) +```bash +$ php PublicModifier.php +``` + +```text +Md. Kabir Khan +``` +
+ +#### [Example for Protected Access Modifier:](ProtectedModifier.php) +```bash +$ php ProtectedModifier.php +``` + +```text +Md. Kabir Khan +``` +
+ +#### [Example for Private Access Modifier:](PrivateModifier.php) +```bash +$ php PrivateModifier.php +``` + +```text +Md. Kabir Khan +``` diff --git a/OOP/Autoload/Autoload.php b/OOP/Autoload/Autoload.php new file mode 100644 index 0000000..5bd17a7 --- /dev/null +++ b/OOP/Autoload/Autoload.php @@ -0,0 +1,49 @@ +getMessage(); +} + +echo $crCtrl->index(); +echo $reCtrl->index(); +echo $upCtrl->index(); +echo $deCtrl->index(); diff --git a/OOP/Autoload/Controllers/CreateController.php b/OOP/Autoload/Controllers/CreateController.php new file mode 100644 index 0000000..7a223cc --- /dev/null +++ b/OOP/Autoload/Controllers/CreateController.php @@ -0,0 +1,9 @@ + The spl_autoload_register() function registers any number of autoloaders, enabling for classes and interfaces to be automatically loaded if they are currently not defined. By registering autoloaders, PHP is given a last chance to load the class or interface before it fails with an error. + +> Many developers writing object-oriented applications create one PHP source file per class definition. One of the biggest annoyances is having to write a long list of needed includes at the beginning of each script (one for each class). + +### Usage: +- Excluding Try and Catch Block: +```php +spl_autoload_register( function($class) { + require 'directory_path/' . $class . '.php'; +}); + +$crCtrl = new CreateController; +$reCtrl = new ReadController; +$upCtrl = new UpdateController; +$deCtrl = new DeleteController; +$unCtrl = new UnknowController; +``` + +- Including Try and Catch Block +```php +spl_autoload_register( + /** + * @throws Exception + */ + function ($class) { + if (file_exists('Controllers/' . $class . '.php')) { + require 'Controllers/' . $class . '.php'; + } else { + throw new Exception('Oops! ' . $class . ' is not exist...' . PHP_EOL); + } + } +); + +try { + $crCtrl = new CreateController; + $reCtrl = new ReadController; + $upCtrl = new UpdateController; + $deCtrl = new DeleteController; + $unCtrl = new UnknowController; +} catch (Exception $e) { + echo $e->getMessage(); +} + +``` + +### Restriction: +Prior to PHP 8.0.0, it was possible to use __autoload() to autoload classes and interfaces. However, it is a less flexible alternative to spl_autoload_register() and __autoload() is deprecated as of PHP 7.2.0, and removed as of PHP 8.0.0. + +
+ +#### [Example of Autoload:](Autoload.php) +```bash +$ php Autoload.php +``` + +```text +This is a CreateController::index method of CreateController +This is a ReadController::index method of ReadController +This is a UpdateController::index method of UpdateController +This is a DeleteController::index method of DeleteController +``` diff --git a/OOP/Basic/Constructor.php b/OOP/Basic/Constructor.php new file mode 100644 index 0000000..11ad285 --- /dev/null +++ b/OOP/Basic/Constructor.php @@ -0,0 +1,18 @@ +person = $name; + $this->profession = $profession; + + echo $this->person . " who designated as a " . $this->profession . PHP_EOL; + } +} + +$rahim = new Constructor('Md. Abdur Rahim', 'Graphics Designer'); +$karim = new Constructor('Md. Karim Ullah', 'Android Developer'); diff --git a/OOP/Basic/Destructor.php b/OOP/Basic/Destructor.php new file mode 100644 index 0000000..5f41933 --- /dev/null +++ b/OOP/Basic/Destructor.php @@ -0,0 +1,18 @@ +person = $name; + } + + public function __destruct() + { + echo $this->person . " who has been subscribed our newsletter. Thanks for be with us..." . PHP_EOL; + } +} + +$rahim = new Destructor('Md. Abdur Rahim'); diff --git a/OOP/Basic/House.php b/OOP/Basic/House.php new file mode 100644 index 0000000..1f24415 --- /dev/null +++ b/OOP/Basic/House.php @@ -0,0 +1,41 @@ + is_array($outside) ? implode(', ', $outside) : $outside, + 'inside_paint' => is_array($inside) ? implode(', ', $inside) : $inside + ); + } + + public function windows($position, $quantity, $width, $height): array + { + return array( + 'window_position' => $position, + 'window_quantity' => $quantity, + 'window_dimension' => '(width) ' . $width . ' X (height) '. $height.' sq.ft' + ); + } + + public function doors($position, $quantity, $width, $height): array + { + return array( + 'door_position' => $position, + 'door_quantity' => $quantity, + 'door_dimension' => '(width) ' . $width . ' X (height) ' . $height . ' inch' + ); + } +} + +$kunjaVilla = new House(); + +print_r($kunjaVilla->colors(['White', 'Red'], ['Blue', 'Green', 'White'])); +print_r($kunjaVilla->windows('Front Side ', 2, 360, 420)); +print_r($kunjaVilla->doors('Main Gate', 1, 360, 760)); + + + + diff --git a/OOP/Basic/README.md b/OOP/Basic/README.md new file mode 100644 index 0000000..d2673f2 --- /dev/null +++ b/OOP/Basic/README.md @@ -0,0 +1,57 @@ +### What is Construct? +> Classes which have a constructor method call this method on each newly-created object, so it is suitable for any initialization that the object may need before it is used. + +### What is Destruct? +> Many developers writing object-oriented applications create one PHP source file per class definition. One of the biggest annoyances is having to write a long list of needed includes at the beginning of each script (one for each class). + +### Usage: +- A `__construct()` allows you to initialize an object's properties upon creation of the object. +- A `__destruct()` is called when the object is destructed, or the script is stopped or exited. + +
+ +#### [Example of House Class:](House.php) +```bash +$ php House.php +``` + +```php +Array +( + [outside_paint] => White, Red + [inside_paint] => Blue, Green, White +) +Array +( + [window_position] => Front Side + [window_quantity] => 2 + [window_dimension] => (width) 360 X (height) 420 sq.ft +) +Array +( + [door_position] => Main Gate + [door_quantity] => 1 + [door_dimension] => (width) 360 X (height) 760 inch +) +``` +
+ +#### [Example of Constructor Class:](Constructor.php) +```bash +$ php Constructor.php +``` + +```text +Md. Abdur Rahim who designated as a Graphics Designer +Md. Karim Ullah who designated as a Android Developer +``` +
+ +#### [Example of Destructor Class:](Destructor.php) +```bash +$ php Destructor.php +``` + +```text +Md. Abdur Rahim who has been subscribed our newsletter. Thanks for be with us... +``` diff --git a/OOP/Database/Database.php b/OOP/Database/Database.php new file mode 100644 index 0000000..05e32c4 --- /dev/null +++ b/OOP/Database/Database.php @@ -0,0 +1,171 @@ +handler = $this->driver . ':host=' . $this->dbHost . ';dbname=' . $this->dbname . ';charset=' . $this->collation; + $this->connect = new PDO($this->handler, $this->dbUser, $this->dbPass); + + try { + if ($this->connect) { + $this->connect->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); + $this->connect->setAttribute(PDO::ATTR_EMULATE_PREPARES, false); + } + } catch (Exception $e) { + return $e->getMessage(); + } + } + + public function all() : bool + { + $statements = "SELECT * FROM $this->table"; + $sqlQueries = $this->connect->prepare($statements); + + try { + if ($sqlQueries->execute()) { + $dataLists = $sqlQueries->fetchAll(PDO::FETCH_ASSOC); + $rowSelect = $sqlQueries->rowCount(); + + if ($rowSelect > 0) { + return $dataLists; + } + } else { + throw new Exception('Something went wrong'); + } + } catch (Exception $e) { + return [$e->getMessage()]; + } + + return true; + } + + public function find($id, $isSingle = false) :array + { + $statements = "SELECT * FROM $this->table WHERE id = $id"; + $sqlQueries = $this->connect->prepare($statements); + + try { + if ($sqlQueries->execute()) { + $dataLists = $sqlQueries->fetchAll(PDO::FETCH_ASSOC); + $rowSelect = $sqlQueries->rowCount(); + + if ($rowSelect > 0) { + if (is_bool($isSingle) && $isSingle === true) { + return $dataLists[0]; + } else { + return $dataLists; + } + } + } + } catch (Exception $e) { + return $e->getMessage(); + } + } + + public function store($name, $email, $mobile, $gender, $profession, $address, $company, $city) { + $statements = "INSERT INTO $this->table ( full_name, email, mobile, gender, profession, address, company, city, created_at ) VALUES ( :FULL_NAME, :EMAIL, :MOBILE, :GENDER, :PROFESSION, :ADDRESS, :COMPANY, :CITY, :CREATED_AT )"; + + $sqlQueries = $this->connect->prepare($statements); + $dataValues = array( + ':FULL_NAME' => $name, + ':EMAIL' => filter_var($email, FILTER_VALIDATE_EMAIL), + ':MOBILE' => $mobile, + ':GENDER' => $gender, + ':PROFESSION' => $profession, + ':ADDRESS' => $address, + ':COMPANY' => $company, + ':CITY' => $city, + ':CREATED_AT' => date('Y-m-d H:i:s'), + ); + + try { + if ($sqlQueries->execute($dataValues)) { + $totalStore = $sqlQueries->rowCount(); + $lastInsert = $this->connect->lastInsertId(); + + if ($lastInsert > 0) { + return array( + 'totalStorage' => $totalStore, + 'lastInsertID' => $lastInsert, + ); + } + } + } catch (Exception $e) { + return $e->getMessage(); + } + } + + public function update($name, $email, $mobile, $gender, $profession, $address, $company, $city, $id) :string + { + $statements = "UPDATE $this->table SET full_name = :FULL_NAME, email = :EMAIL, mobile = :MOBILE, gender = :GENDER, profession = :PROFESSION, address = :ADDRESS, company = :COMPANY, city = :CITY, updated_at = :UPDATED_AT WHERE id = :UPDATE_ID"; + + $sqlQueries = $this->connect->prepare($statements); + $dataValues = array( + ':FULL_NAME' => $name, + ':EMAIL' => filter_var($email, FILTER_VALIDATE_EMAIL), + ':MOBILE' => $mobile, + ':GENDER' => $gender, + ':PROFESSION' => $profession, + ':ADDRESS' => $address, + ':COMPANY' => $company, + ':CITY' => $city, + ':UPDATED_AT' => date('Y-m-d H:i:s'), + ':UPDATE_ID' => $id, + ); + + try { + if ($sqlQueries->execute($dataValues)) { + return $sqlQueries->rowCount(); + } + } catch (Exception $e) { + return $e->getMessage(); + } + } + + public function delete($id) :string + { + $statements = "DELETE FROM $this->table WHERE id = :ID"; + $sqlQueries = $this->connect->prepare($statements); + $dataValues = array(':ID' => $id); + + try { + if ($sqlQueries->execute($dataValues)) { + $rowNumber = $sqlQueries->rowCount(); + + if ($rowNumber > 0) { + return $rowNumber; + } + } + } catch (Exception $e) { + return $e->getMessage(); + } + } +} + +$db = new Database; + + +$allEmployees = $db->all(); +$findEmployee = $db->find(22, true); +$addNewEmploy = $db->store('Kabir Khan', 'kabir@gmail.com', '191-110-4547', 'Male', 'Applicaton Developer', 'Panthapath-1206', 'Freelancing', 'Dhaka'); +$deleteEmploy = $db->delete(22); +$updateEmploy = $db->update('Jhon Doe', 'jhon@gmail.com', '191-110-4547', 'Female', 'Applicaton Developer', 'Panthapath-1206', 'Freelancing', 'Dhaka', 22); + diff --git a/OOP/Database/DatabaseController.php b/OOP/Database/DatabaseController.php new file mode 100644 index 0000000..5666618 --- /dev/null +++ b/OOP/Database/DatabaseController.php @@ -0,0 +1,7 @@ + A PHP interface defines a contract which a class must fill using methods. If a PHP class is a blueprint for objects, an interface is a blueprint for classes. Any class implementing a given interface can be expected to have the same behavior in terms of what can be called, how it can be called, and what will be returned. + +> An Interface allows the users to create programs, specifying the public methods that a class must implement, without involving the complexities and details of how the particular methods are implemented. It is generally referred to as the next level of abstraction. It resembles the abstract methods, resembling the abstract classes. + + +### Usages: +- [x] Interfaces are declared with the ``` interface ``` keyword. +- [x] To implement an interface, a class must use the ``` implements ``` keyword. + + +### Interfaces vs. Abstract Classes: +Interface are similar to abstract classes. The difference between interfaces and abstract classes are: +* Interfaces cannot have properties, while abstract classes can +* All interface methods must be public, while abstract class methods is public or protected +* All methods in an interface are abstract, so they cannot be implemented in code, and the abstract keyword is not necessary +* Classes can implement an interface while inheriting from another class at the same time + + +###### Example for Employees Class: +``` +$ php Employees.php +``` + +``` +This class statement is represent for Employees + +Array +( + [first_name] => Md. Rahim + [last_name] => Uddin + [age] => 30 + [email] => rahim@gmail.com + [mobile] => +88 01316-440504 + [designation] => Technical Operator + [organization] => ABC International Limited + [location] => Dhaka-1206, Bangladesh + [street] => Pathapath-1206 + [city] => Dhaka + [country] => Bangladesh +) +``` + +###### Example for Manager Class: +``` +$ php Managers.php +``` + +``` +This class statement is represent for Managers + +Array +( + [first_name] => Md. Kabir + [last_name] => Khan + [age] => 32 + [email] => kabir.khan@gmail.com + [mobile] => +88 01316-440497 + [designation] => Technical Manager + [organization] => ABC International Limited + [location] => Dhaka-1206, Bangladesh + [street] => Pathapath-1206 + [city] => Dhaka + [country] => Bangladesh +) +``` diff --git a/OOP/Dependency Injection/Author.php b/OOP/Dependency Injection/Author.php new file mode 100644 index 0000000..6c36bb9 --- /dev/null +++ b/OOP/Dependency Injection/Author.php @@ -0,0 +1,31 @@ +name = $arr[0]; + $this->dob = @$arr[1]; + $this->about = @$arr[2]; + $this->quotes = @$arr[3]; + } + } + + public function getAuthorBio() : array + { + return array( + 'name' => $this->name, + 'birthDate' => $this->dob, + 'about' => $this->about, + 'quotes' => $this->quotes + ); + } +} diff --git a/OOP/Dependency Injection/Book.php b/OOP/Dependency Injection/Book.php new file mode 100644 index 0000000..b9cbc2f --- /dev/null +++ b/OOP/Dependency Injection/Book.php @@ -0,0 +1,41 @@ +title = trim(addslashes($title)); + $this->language = $lang; + $this->isbn = bin2hex(base64_encode('ISBN' . rand(11111, 99999))); + $this->pages = $page; + $this->edition = $edition . ' Edition'; + $this->author = new Author($author); + $this->publisher = new Publisher($publisher); + } + + public function getBookInformation(): array + { + return array( + 'bookTitle' => $this->title, + 'language' => $this->language, + 'isbn_no' => $this->isbn, + 'pages' => $this->pages, + 'edition' => $this->edition, + 'author' => $this->author->getAuthorBio(), + 'publisher' => $this->publisher->getPublisherInfo() + ); + } +} diff --git a/OOP/Dependency Injection/Publisher.php b/OOP/Dependency Injection/Publisher.php new file mode 100644 index 0000000..a2c1e5f --- /dev/null +++ b/OOP/Dependency Injection/Publisher.php @@ -0,0 +1,37 @@ +store = $arr[0]; + $this->contact = trim(addslashes(@$arr[1])); + $this->address = trim(addslashes(@$arr[2])); + $this->rating = trim(addslashes(@$arr[3])); + $this->reviews = trim(addslashes(@$arr[4])); + $this->isOpen = trim(addslashes(@$arr[5])); + } + } + + public function getPublisherInfo() : array + { + return array( + 'title' => $this->store, + 'contact' => $this->contact, + 'address' => $this->address, + 'rating' => $this->rating, + 'review' => $this->reviews, + 'status' => $this->isOpen + ); + } +} diff --git a/OOP/Dependency Injection/index.php b/OOP/Dependency Injection/index.php new file mode 100644 index 0000000..d03e494 --- /dev/null +++ b/OOP/Dependency Injection/index.php @@ -0,0 +1,11 @@ +getBookInformation()); diff --git a/OOP/Functions/Conditional/ExtendedClass.php b/OOP/Functions/Conditional/ExtendedClass.php new file mode 100644 index 0000000..c1232f8 --- /dev/null +++ b/OOP/Functions/Conditional/ExtendedClass.php @@ -0,0 +1,11 @@ +className(); +// print_r($object->classMethods()); +// echo Activities::getCalledClass(); + diff --git a/OOP/Functions/Get/ActivitiesInterface.php b/OOP/Functions/Get/ActivitiesInterface.php new file mode 100644 index 0000000..f7c0c98 --- /dev/null +++ b/OOP/Functions/Get/ActivitiesInterface.php @@ -0,0 +1,8 @@ +parentClassName(); + print_r($extend->classVariables()); + print_r($extend->objectVariables()); + echo ExtendActivities::getCalledClass(); + print_r($extend->getDeclaredClass()); diff --git a/OOP/Functions/GetFunction.php b/OOP/Functions/GetFunction.php new file mode 100644 index 0000000..d3b48c2 --- /dev/null +++ b/OOP/Functions/GetFunction.php @@ -0,0 +1,54 @@ +firstName . ' ' . $exAct->lastName . PHP_EOL; diff --git a/OOP/Functions/README.md b/OOP/Functions/README.md new file mode 100644 index 0000000..b0d2d63 --- /dev/null +++ b/OOP/Functions/README.md @@ -0,0 +1,140 @@ +### What is Get Functions? + +--- + + +### What is Conditional Functions? + +--- + + +#### [List of Get Functions and Usage:](GetFunction.php) + +--- +`get_class` +```php +$object = new Activities(); +echo 'Class name is: ' . get_class($object) . PHP_EOL; +``` + +`get_parent_class` +```php +$extend = new ExtendActivities(); +echo 'Parent class name is: ' . get_parent_class($extend) . PHP_EOL; +``` + +`get_class_methos` +```php +$object = new Activities(); +print_r(get_class_methods($object)); +``` + +`get_class_vars` +```php +$extend = new ExtendActivities(); +print_r(get_class_vars(get_class($extend))); +``` + +`get_object_vars` +```php +$extend = new ExtendActivities(); +print_r(get_object_vars($extend)); +``` + +`get_called_class` +```php +echo Activities::getCalledClass(); +echo ExtendActivities::getCalledClass(); +``` + +`get_declared_classes` +```php +print_r(get_declared_classes()); +``` + +`get_declared_interfaces` +```php +print_r(get_declared_interfaces()); +``` + +`get_declared_traits` +```php +print_r(get_declared_traits()); +``` + +`class_alias` +```php +class_alias('ExtendActivities', 'ExAct'); +$exAct = new ExAct(); +echo $exAct->firstName . ' ' . $exAct->lastName . PHP_EOL; +``` +
+ +#### [List of Conditional Functions and Usage:](ConditionalFunction.php) + +--- + +`class_exists` +```php +if (class_exists('SimpleClass')) { + echo 'class is exist' . PHP_EOL; +} else { + echo 'Oops! class is not exist' . PHP_EOL; +} +``` + +`interface_exists` +```php +if (interface_exists('SimpleInterface')) { + echo 'interface is exist' . PHP_EOL; +} else { + echo 'Oops! interface is not exist' . PHP_EOL; +} +``` + +`method_exists` +```php +$object = new SimpleClass(); + +if (method_exists($object, 'index')) { + echo 'method is exist' . PHP_EOL; +} else { + echo 'Oops! method is not exist' . PHP_EOL; +} +``` + +`trait_exists` +```php +if (trait_exists('SimpleTrait')) { + echo 'trait is exist' . PHP_EOL; +} else { + echo 'Oops! trait is not exist' . PHP_EOL; +} +``` + +`property_exists` +```php +if (property_exists('SimpleTrait', 'firstName')) { + echo 'property is exist' . PHP_EOL; +} else { + echo 'Oops! property is not exist' . PHP_EOL; +} +``` + +`is_a` +```php +if (is_a($object, 'SimpleClass')) { + echo '$object is instantiate based on SimpleClass' . PHP_EOL; +} else { + echo 'Oops! $object is not instantiate based on SimpleClass' . PHP_EOL; +} +``` + +`is_subclass_of` +```php +if (is_subclass_of($extend, 'SimpleClass')) { + echo '$extend is instantiate based on ExtendedClass which extended from SimpleClass' . PHP_EOL; +} else { + echo 'Oops! $extend is not instantiate based on ExtendedClass which extended from SimpleClass' . PHP_EOL; +} +``` diff --git a/OOP/Inheritance/BalanceSheet.php b/OOP/Inheritance/BalanceSheet.php new file mode 100644 index 0000000..c480e57 --- /dev/null +++ b/OOP/Inheritance/BalanceSheet.php @@ -0,0 +1,29 @@ +totalSalary = $totalSalary; + + return [ + 'accountDetails' => $this->bankAccount($bank, $branch, $accountNo, $accountHolder, $currency), + 'salaryDetails' => [ + 'basic_salary' => $this->basicSalary() . ' ' . $this->txnCurrency, + 'provident_fund' => $this->providentFund() . ' ' . $this->txnCurrency, + 'salary_increment' => $this->salaryIncrement() . ' ' . $this->txnCurrency, + 'total_salary' => $this->totalSalary . ' ' . $this->txnCurrency + ] + ]; + } +} + +$rahim = new BalanceSheet(); +$karim = new BalanceSheet(); + +$rahimAccounts = $rahim->userAccountDetails('Eastern Bank Limited', 'Dhaka-1206', '4512-8754-6531', 'Abdur Rahim', 'BDT', 22150); +$karimAccounts = $karim->userAccountDetails('Dutch Bangla Bank Limited', 'Dhaka-1206', '7851-2474-5421', 'Karim Hossain', 'BDT', 27000); + +print_r($rahimAccounts); diff --git a/OOP/Inheritance/Controllers/AccountController.php b/OOP/Inheritance/Controllers/AccountController.php new file mode 100644 index 0000000..a2c812f --- /dev/null +++ b/OOP/Inheritance/Controllers/AccountController.php @@ -0,0 +1,27 @@ +bankName = $bank; + $this->branchAddress = $branch; + $this->accountNumber = $accountNo; + $this->accountHolder = $accountHolder; + $this->txnCurrency = $currency; + + return [ + 'bank_name' => $this->bankName, + 'branch_address' => $this->branchAddress, + 'account_number' => $this->accountNumber, + 'account_holder' => $this->accountHolder, + 'txn_currency' => $this->txnCurrency, + ]; + } +} diff --git a/OOP/Inheritance/Controllers/ProfileController.php b/OOP/Inheritance/Controllers/ProfileController.php new file mode 100644 index 0000000..5ac8737 --- /dev/null +++ b/OOP/Inheritance/Controllers/ProfileController.php @@ -0,0 +1,19 @@ +fullName = $name; + $this->age = $age; + $this->profession = $profession; + + return [get_class($this) => [ + 'full_name' => $this->fullName, 'age' => $this->age, 'profession' => $this->profession] + ]; + } +} diff --git a/OOP/Inheritance/Controllers/SalarySheetController.php b/OOP/Inheritance/Controllers/SalarySheetController.php new file mode 100644 index 0000000..c8f32d1 --- /dev/null +++ b/OOP/Inheritance/Controllers/SalarySheetController.php @@ -0,0 +1,29 @@ +basicSalary = $this->totalSalary * 0.45; + return $this->basicSalary; + } + + protected function providentFund(): float + { + $this->providentFund = $this->totalSalary * 0.15; + return $this->providentFund; + } + + protected function salaryIncrement(): float + { + $this->salaryIncrement = $this->totalSalary * 0.2; + return $this->salaryIncrement; + } +} diff --git a/OOP/Inheritance/EmployeeProfile.php b/OOP/Inheritance/EmployeeProfile.php new file mode 100644 index 0000000..36f0c2f --- /dev/null +++ b/OOP/Inheritance/EmployeeProfile.php @@ -0,0 +1,16 @@ +information('Abdur Rahim', 32, 'Graphic Designer')); + + diff --git a/OOP/Inheritance/ManagerProfile.php b/OOP/Inheritance/ManagerProfile.php new file mode 100644 index 0000000..4dd1e9b --- /dev/null +++ b/OOP/Inheritance/ManagerProfile.php @@ -0,0 +1,14 @@ +information('Saleh Ahmed', 37, 'Head of Department')); diff --git a/OOP/Inheritance/README.md b/OOP/Inheritance/README.md new file mode 100644 index 0000000..e035b86 --- /dev/null +++ b/OOP/Inheritance/README.md @@ -0,0 +1,81 @@ +### What is Inheritance? +> When a class derives from another class. The child class will inherit all the public and protected properties and methods from the parent class. In addition, it can have its own properties and methods. + + +### Type of Inheritance: +- Single Inheritance +- Multiple Inheritance +- Multi Level Inheritance +- Hybrid Inheritance +- Hierarchical Inheritance + +![Inheritance](./../../../assets/inheritance.png) + +### Usages and Restriction: +- An inherited class is defined by using the `extends` keyword. +- PHP does not allow `multiple inheritance`, it allow only `multilevel inheritance`. + +
+ +#### [Example for Employee Profile:](EmployeeProfile.php) +```bash +$ php EmployeeProfile.php +``` + +```php +Array +( + [EmployeeProfile] => Array + ( + [full_name] => Abdur Rahim + [age] => 32 + [profession] => Graphic Designer + ) +) +``` +
+ +#### [Example for Manager Profile:](ManagerProfile.php) +```bash +$ php ManagerProfile.php +``` + +```php +Array +( + [ManagerProfile] => Array + ( + [full_name] => Saleh Ahmed + [age] => 37 + [profession] => Head of Department + ) +) +``` +
+ +#### [Example for Multi Level Inheritance:](BalanceSheet.php) +```bash +$ php BalanceSheet.php +``` + +```php +Array +( + [accountDetails] => Array + ( + [bank_name] => Eastern Bank Limited + [branch_address] => Dhaka-1206 + [account_number] => 4512-8754-6531 + [account_holder] => Abdur Rahim + [txn_currency] => BDT + ) + + [salaryDetails] => Array + ( + [basic_salary] => 9967.5 BDT + [provident_fund] => 3322.5 BDT + [salary_increment] => 4430 BDT + [total_salary] => 22150 BDT + ) +) +``` diff --git a/OOP/Interface/Employees.php b/OOP/Interface/Employees.php new file mode 100644 index 0000000..eb39255 --- /dev/null +++ b/OOP/Interface/Employees.php @@ -0,0 +1,56 @@ +biography, ['first_name' => $fName, 'last_name' => $lName, 'age' => $age, 'email' => $email, 'mobile' => $mobile]); + } + + public function profession($designation, $organization, $location): void + { + array_push($this->biography, ['designation' => $designation, 'organization' => $organization, 'location' => $location]); + } + + public function address($street, $city, $country): void + { + array_push($this->biography, ['street' => $street, 'city' => $city, 'country' => $country]); + } + + public function excerptDetails(): array + { + if (!empty($this->biography) && is_array($this->biography)) { + $index = $value = []; + + foreach ($this->biography as $bio) { + foreach ($bio as $n => $each) { + $index[] = $n; + $value[] = $each; + } + } + + if (is_array($index) && is_array($value)) { + $this->summaries = array_combine($index, $value); + } + } + + return $this->summaries; + } +} + +$rahim = new Employees(); +$rahim->profile('Md. Rahim', 'Uddin', 30, 'rahim@gmail.com', '+88 01316-440504'); +$rahim->profession('Technical Operator', 'ABC International Limited', 'Dhaka-1206, Bangladesh'); +$rahim->address('Pathapath-1206', 'Dhaka', 'Bangladesh'); + +print_r($rahim->excerptDetails()); diff --git a/OOP/Interface/HumanResourceInterfaces.php b/OOP/Interface/HumanResourceInterfaces.php new file mode 100644 index 0000000..2ec93c9 --- /dev/null +++ b/OOP/Interface/HumanResourceInterfaces.php @@ -0,0 +1,9 @@ +biography, ['first_name' => $fName, 'last_name' => $lName, 'age' => $age, 'email' => $email, 'mobile' => $mobile]); + } + + public function profession($designation, $organization, $location): void + { + array_push($this->biography, ['designation' => $designation, 'organization' => $organization, 'location' => $location]); + } + + public function address($street, $city, $country): void + { + array_push($this->biography, ['street' => $street, 'city' => $city, 'country' => $country]); + } + + public function excerptDetails(): array + { + if (!empty($this->biography) && is_array($this->biography)) { + $index = $value = []; + + foreach ($this->biography as $bio) { + foreach ($bio as $n => $each) { + $index[] = $n; + $value[] = $each; + } + } + + if (is_array($index) && is_array($value)) { + $this->summaries = array_combine($index, $value); + } + } + + return $this->summaries; + } +} + +$kabir = new ManagerProfile(); +$kabir->profile('Md. Kabir', 'Khan', 32, 'kabir.khan@gmail.com', '+88 01316-440497'); +$kabir->profession('Technical Manager', 'ABC International Limited', 'Dhaka-1206, Bangladesh'); +$kabir->address('Pathapath-1206', 'Dhaka', 'Bangladesh'); + +print_r($kabir->excerptDetails()); diff --git a/OOP/Interface/README.md b/OOP/Interface/README.md new file mode 100644 index 0000000..fb1f9f4 --- /dev/null +++ b/OOP/Interface/README.md @@ -0,0 +1,62 @@ +### What is Interface? +> A PHP interface defines a contract which a class must fill using methods. If a PHP class is a blueprint for objects, an interface is a blueprint for classes. Any class implementing a given interface can be expected to have the same behavior in terms of what can be called, how it can be called, and what will be returned. + +> An Interface allows the users to create programs, specifying the public methods that a class must implement, without involving the complexities and details of how the particular methods are implemented. It is generally referred to as the next level of abstraction. It resembles the abstract methods, resembling the abstract classes. + + +### Usages: +- [x] Interfaces are declared with the ``` interface ``` keyword. +- [x] To implement an interface, a class must use the ``` implements ``` keyword. + + +### Interfaces vs. Abstract Classes: +Interface are similar to abstract classes. The difference between interfaces and abstract classes are: +* Interfaces cannot have properties, while abstract classes can +* All interface methods must be public, while abstract class methods is public or protected +* All methods in an interface are abstract, so they cannot be implemented in code, and the abstract keyword is not necessary +* Classes can implement an interface while inheriting from another class at the same time + + +#### Example for Employees Class: +```bash +$ php Employees.php +``` + +```php +Array +( + [first_name] => Md. Rahim + [last_name] => Uddin + [age] => 30 + [email] => rahim@gmail.com + [mobile] => +88 01316-440504 + [designation] => Technical Operator + [organization] => ABC International Limited + [location] => Dhaka-1206, Bangladesh + [street] => Pathapath-1206 + [city] => Dhaka + [country] => Bangladesh +) +``` + +#### Example for Manager Class: +```bash +$ php Managers.php +``` + +```php +Array +( + [first_name] => Md. Kabir + [last_name] => Khan + [age] => 32 + [email] => kabir.khan@gmail.com + [mobile] => +88 01316-440497 + [designation] => Technical Manager + [organization] => ABC International Limited + [location] => Dhaka-1206, Bangladesh + [street] => Pathapath-1206 + [city] => Dhaka + [country] => Bangladesh +) +``` diff --git a/OOP/MagicConstant/ConstantClass.php b/OOP/MagicConstant/ConstantClass.php new file mode 100644 index 0000000..7465923 --- /dev/null +++ b/OOP/MagicConstant/ConstantClass.php @@ -0,0 +1,20 @@ + ' . __CLASS__ . PHP_EOL; + } + + public function getMethodName(): string + { + return 'The method name is => ' . __METHOD__ . PHP_EOL; + } +} + +$const = new ConstantClass(); + +echo $const->getClassName(); +echo $const->getMethodName(); diff --git a/OOP/MagicConstant/ConstantNameSpace.php b/OOP/MagicConstant/ConstantNameSpace.php new file mode 100644 index 0000000..8936e3a --- /dev/null +++ b/OOP/MagicConstant/ConstantNameSpace.php @@ -0,0 +1,16 @@ + ' . __NAMESPACE__ . PHP_EOL; + } +} + +$const = new ConstantNameSpace(); +echo $const->getNameSpace(); diff --git a/OOP/MagicConstant/ConstantTrait.php b/OOP/MagicConstant/ConstantTrait.php new file mode 100644 index 0000000..4bb93e5 --- /dev/null +++ b/OOP/MagicConstant/ConstantTrait.php @@ -0,0 +1,18 @@ + ' . __TRAIT__ . PHP_EOL; + } +} + +class ParseTrait +{ + use ConstantTrait; +} + +$const = new ParseTrait(); +echo $const->getTrait(); diff --git a/OOP/MagicConstant/Constants.php b/OOP/MagicConstant/Constants.php new file mode 100644 index 0000000..4ecb5b1 --- /dev/null +++ b/OOP/MagicConstant/Constants.php @@ -0,0 +1,33 @@ + ' . __LINE__ . PHP_EOL; + } + + public function getFilePath(): string + { + return 'The file path is => ' . __FILE__ . PHP_EOL; + } + + public function getDirectory(): string + { + return 'The directory is => ' . __DIR__ . PHP_EOL; + } + + public function getFunction(): string + { + return 'The function is => ' . __FUNCTION__ . PHP_EOL; + } +} + + +$const = new Constants(); + +echo $const->getLineNo(); +echo $const->getFilePath(); +echo $const->getDirectory(); +echo $const->getFunction(); diff --git a/OOP/MagicConstant/README.md b/OOP/MagicConstant/README.md new file mode 100644 index 0000000..8379f3a --- /dev/null +++ b/OOP/MagicConstant/README.md @@ -0,0 +1,78 @@ +### What is Magic Constant? +> Magic constants are the predefined constants in PHP which is used on the basis of their use. These constants are created by various extensions. There are nine magic constant in the PHP and all of the constant resolved at the compile-time, not like the regular constant which is resolved at run time. There are eight magic constants that start and end with double underscores (__). + + +### Magic Constants: +- [x] ``` __LINE__ ``` The current line number of the file. +- [x] ``` __FILE__ ``` The full path and filename of the file with symlinks resolved. +- [x] ``` __DIR__ ``` The directory of the file. This is equivalent to ```dirname(__FILE__)```. +- [x] ``` __FUNCTION__ ``` The function name, or {closure} for anonymous functions. +- [x] ``` __CLASS__ ``` The class name. The class name includes the namespace it was declared. +- [x] ``` __METHOD__ ``` The class method name. +- [x] ``` __NAMESPACE__ ``` The name of the current namespace. +- [x] ``` __TRAIT__ ``` The trait names. The trait name includes the namespace it was declared. + + +### Limitation or Restriction: +* ```__LINE__``` and ```__FILE__``` and ```__DIR__``` and ```__FUNCTION__``` are could be used anywhere in PHP application. +* ```__CLASS__``` and ```__METHOD__``` and ```__NAMESPACE__``` and ```__TRAIT__``` are could be used only in OOP. + +
+ +#### [Example of Constant:](Constants.php) +```bash +$ php Constants.php +``` + +```text +The line no is => 8 +The file path is => D:\xampp\htdocs\fleet-learning-courses\php\oop\MagicConstant\Constants.php +The directory is => D:\xampp\htdocs\fleet-learning-courses\php\oop\MagicConstant +The function is => getFunction +``` +N:B: Might be differed due to execution directory or path... + +
+ +#### [Example of Constant Class:](ConstantClass.php) +```bash +$ php ConstantClass.php +``` + +```text +The class name is => ConstantClass +The method name is => ConstantClass::getMethodName +``` + +
+ +#### [Example of Constant Namespace Class:](ConstantNamespace.php) +```bash +$ php ConstantNamespace.php +``` +```text +The namespace of this class is => App\MagicConstant +``` +
+ +#### [Example of Constant Trait Class:](ConstantTrait.php) +```bash +$ php ConstantTrait.php +``` + +```text +The trait is => ConstantTrait +``` +
+ +#### [Example of Functions:](functions.php) +```bash +$ php functions.php +``` + +```text +Current line no is => 3 +Current file path is => D:\xampp\htdocs\fleet-learning-courses\php\oop\MagicConstant\functions.php +Current directory is => D:\xampp\htdocs\fleet-learning-courses\php\oop\MagicConstant +Current function is => getFunction +``` diff --git a/OOP/MagicConstant/functions.php b/OOP/MagicConstant/functions.php new file mode 100644 index 0000000..154291e --- /dev/null +++ b/OOP/MagicConstant/functions.php @@ -0,0 +1,12 @@ + ' . __LINE__ . PHP_EOL; + +echo 'Current file path is => ' . __FILE__ . PHP_EOL; + +echo 'Current directory is => ' . __DIR__ . PHP_EOL; + +function getFunction() { + echo 'Current function is => ' . __FUNCTION__ . PHP_EOL; +} +getFunction(); diff --git a/OOP/MagicMethod/Call/Call.php b/OOP/MagicMethod/Call/Call.php new file mode 100644 index 0000000..ada62ed --- /dev/null +++ b/OOP/MagicMethod/Call/Call.php @@ -0,0 +1,43 @@ +name = $name; + $this->email = $email; + $this->mobile = $mobile; + + $this->details = ['name' => $this->name, 'email' => $this->email, 'mobile' => $this->mobile]; + return $this->details; + } + + private function userAddress($street, $city, $country) { + $this->street = $street; + $this->city = $city; + $this->country = $country; + + $this->details = ['street' => $this->street, 'city' => $this->city, 'country' => $this->country]; + return $this->details; + } + + public function __call($method, $args) { + return ['messages' => 'Oops! unable to access on private "' . $method . '"" method', 'argument' => $args]; + } +} + +$object = new Call(); + +echo '
';
+print_r($object->userInfo('Kabir Khan', 'kabir.khan@gmail.com', '+88 01645-770422'));
+print_r($object->userAddress('Basundhara Shopping Complex, Pathapath', 'Dhaka-1206', 'Bangladesh'));
+echo '
'; \ No newline at end of file diff --git a/OOP/MagicMethod/Call/CallStatic.php b/OOP/MagicMethod/Call/CallStatic.php new file mode 100644 index 0000000..090aa95 --- /dev/null +++ b/OOP/MagicMethod/Call/CallStatic.php @@ -0,0 +1,17 @@ +fullName = $name; + echo "Hey " . $this->fullName . " Have a good day \n"; + } +} + +$kabir = new CloneClass('Kabir Khan'); +$jhon = clone $kabir; +$jhon->fullName = 'Jhon Doe'; + +echo $kabir->fullName . "\n"; +echo $jhon->fullName . "\n"; + +const App = 'Something'; + +echo App . "\n";; + +$constants = get_defined_constants(); +echo '
';
+print_r($constants); // pretty large list
+echo '
'; \ No newline at end of file diff --git a/OOP/MagicMethod/Clone/README.md b/OOP/MagicMethod/Clone/README.md new file mode 100644 index 0000000..e69de29 diff --git a/OOP/MagicMethod/Invoke/Invoke.php b/OOP/MagicMethod/Invoke/Invoke.php new file mode 100644 index 0000000..a4167a1 --- /dev/null +++ b/OOP/MagicMethod/Invoke/Invoke.php @@ -0,0 +1,72 @@ +a = $num1; + $this->b = $num2; + + try { + if (!empty($type) && $type == 'addition') { + $data = $this->addition(); + } elseif (!empty($type) && $type == 'subtraction') { + $data = $this->subtraction(); + } elseif (!empty($type) && $type == 'multiplication') { + $data = $this->multiplication(); + } elseif (!empty($type) && $type == 'division') { + $data = $this->division(); + } elseif (!empty($type) && $type == 'remainder') { + $data = $this->remainder(); + } else { + throw new Exception('Calculation type is required'); + } + } catch (Exception $e) { + $data = $e->getMessage(); + } + + return $data; + } + + protected function addition(): string + { + $this->result = $this->a + $this->b; + return 'Total addition value is = ' . $this->result; + } + + protected function subtraction(): void { + $this->result = $this->a - $this->b; + echo 'Total subtraction value is = ' . $this->result; + } + + protected function multiplication() { + $this->result = $this->a * $this->b; + echo 'Total multiplication value is = ' . $this->result; + } + + protected function division() { + $this->result = $this->a / $this->b; + echo 'Total division value is = ' . $this->result; + } + + protected function remainder() { + $this->result = $this->a % $this->b; + echo 'Total division value is = ' . $this->result; + } + + public function __invoke() { + return $this->result; + } +} + + +$calculate = new Calculation('remainder', 25, 7); +$calculate(); diff --git a/OOP/MagicMethod/Invoke/README.md b/OOP/MagicMethod/Invoke/README.md new file mode 100644 index 0000000..e69de29 diff --git a/OOP/MagicMethod/Isset/Isset.php b/OOP/MagicMethod/Isset/Isset.php new file mode 100644 index 0000000..28982e4 --- /dev/null +++ b/OOP/MagicMethod/Isset/Isset.php @@ -0,0 +1,44 @@ +title = 'ABC International Company Ltd.'; + $this->address = 'Bashundhra City, Panthapath'; + $this->city = 'Dhaka-1206'; + $this->email = 'info.admin@abc.org'; + $this->mobile = '+880 1459-875421'; + + return $this->details = [ + 'title' => $this->title, + 'address'=> $this->address, + 'city' => $this->city, + 'email' => $this->email, + 'mobile' => $this->mobile + ]; + } + + public function __isset($param) { + return $this->property = $param; + } +} + +$abc = new Organization; +// print_r($abc->profile()); +echo isset($abc->property); \ No newline at end of file diff --git a/OOP/MagicMethod/Isset/README.md b/OOP/MagicMethod/Isset/README.md new file mode 100644 index 0000000..e69de29 diff --git a/OOP/MagicMethod/Sleep/README.md b/OOP/MagicMethod/Sleep/README.md new file mode 100644 index 0000000..e69de29 diff --git a/OOP/MagicMethod/Sleep/SleepMethod.php b/OOP/MagicMethod/Sleep/SleepMethod.php new file mode 100644 index 0000000..c97fd10 --- /dev/null +++ b/OOP/MagicMethod/Sleep/SleepMethod.php @@ -0,0 +1,51 @@ +platform = $param; + + if (!empty($this->platform) || isset($this->platform)) { + $this->token = sha1($this->platform); + $this->latitude = rand(20, 50) . '.' . rand(00000, 50000); + $this->longitude = rand(50, 99) . '.' . rand(50000, 99999); + } + + return array( + 'Platform' => $this->platform, + 'Token' => $this->token, + 'Latitude' => $this->latitude, + 'Longitude' => $this->longitude + ); + } + + public function __sleep() :array + { + return array('platform', 'token'); + } +} + +$object = new SleepMethod(); +$object->clientDevice('Google Chrome 88.7'); + +$convertSerialize = serialize($object); +print_r($convertSerialize) . PHP_EOL; + +$convertArray = unserialize($convertSerialize); +print_r($convertArray) . PHP_EOL; diff --git a/OOP/MagicMethod/Unset/README.md b/OOP/MagicMethod/Unset/README.md new file mode 100644 index 0000000..e69de29 diff --git a/OOP/MagicMethod/Unset/UnsetMethod.php b/OOP/MagicMethod/Unset/UnsetMethod.php new file mode 100644 index 0000000..1dcfa68 --- /dev/null +++ b/OOP/MagicMethod/Unset/UnsetMethod.php @@ -0,0 +1,71 @@ +bankAccount = md5($name); + $this->accountHolder = $name; + + $parseUserName = explode(' ', $name); + if (!empty($parseUserName) && is_array($parseUserName)) { + $this->userName = next($parseUserName); + } + + return $this->userName; + } + + + public function details(): array + { + try { + if (isset($this->bankAccount) && isset($this->accountHolder) ) { + $this->detailsInfo = [ + 'user_name' => $this->userName, + 'bank_account' => $this->bankAccount, + 'account_holder' => $this->accountHolder + ]; + } else { + throw new Exception("Oops! $" . $this->unsetProperty . " value is unset"); + // throw new Exception('Oops! Something went wrong'); + } + } catch (Exception $e) { + $this->detailsInfo = ['Error Occurred' => $e->getMessage()]; + } + + return [ + 'Greeting' => "Hello " . $this->userName . ", have a good day ", + 'Details' => $this->detailsInfo + ]; + } + + + public function __unset($property): void + { + $this->unsetProperty = $property . ' = "' . $this->$property . '"'; + unset($this->$property); + } +} + +$object = new UnsetMethod(); +$object->setPerson('Abdur Rahim Uddin'); + +//unset($object->bankAccount); +//print_r($object); +print_r($object->details()); diff --git a/OOP/MagicMethod/Wakeup/README.md b/OOP/MagicMethod/Wakeup/README.md new file mode 100644 index 0000000..e69de29 diff --git a/OOP/MagicMethod/Wakeup/WakeupMethod.php b/OOP/MagicMethod/Wakeup/WakeupMethod.php new file mode 100644 index 0000000..fbdd066 --- /dev/null +++ b/OOP/MagicMethod/Wakeup/WakeupMethod.php @@ -0,0 +1,14 @@ +query = "SELECT * FROM "; + return $this; + } + + public function sqlCode($table): Eloquent + { + $this->query .= $table; + return $this; + } + + public function whereValue($id): Eloquent + { + $this->query .= " WHERE id = {$id}"; + return $this; + } + + public function and($col, $str): Eloquent + { + $this->query .= " AND {$col} = \"{$str}\""; + return $this; + } + + public function or($col, $str): Eloquent + { + $this->query .= " OR {$col} = \"{$str}\""; + return $this; + } + + public function orderBy($order = 'ASC'): Eloquent + { + $this->query .= " ORDER BY {$order}"; + return $this; + } + + public function result(): string + { + return $this->query; + } +} + +$query = new Eloquent(); +$users = $query->all() + ->sqlCode('users') + ->whereValue(5) + ->and('first_name', 'Jobayer') + ->or('gender', 'Male') + ->orderBy('DESC') + ->result(); + +echo $users; diff --git a/OOP/MethodChaining/ObjectRelation.php b/OOP/MethodChaining/ObjectRelation.php new file mode 100644 index 0000000..e2faab8 --- /dev/null +++ b/OOP/MethodChaining/ObjectRelation.php @@ -0,0 +1,61 @@ +sqlCode('admins') + ->whereValue(3) + ->and('isLogin', 'Yes') + ->or('isActive', 'Active') + ->orderBy() + ->result(); + +echo $admins; diff --git a/OOP/MethodChaining/README.md b/OOP/MethodChaining/README.md new file mode 100644 index 0000000..3c28a53 --- /dev/null +++ b/OOP/MethodChaining/README.md @@ -0,0 +1,61 @@ +### What is Method Chaining? + +--- +Method chaining is a fluent interface design pattern used to simplify your code. If you've used frameworks like Zend or jQuery, you probably have some experience with chaining. Essentially your objects return themselves, allowing you to "chain" multiple actions together. + +### Usage: + +--- +- In PHP, `$this` keyword references the current object of the class. The `$this` keyword allows you to access the properties and methods of the current object within the class using the object operator `(->)` +- Make sure that excluding `static` function all functions should be `non-static` as well. +- To bind as a chain functions return type must be `return $this`; + +### Syntax: + +--- +- [x] Using Non-Static Classes: +```php +$query = new Eloquent(); +$users = $query->all() + ->sqlCode('users') + ->whereValue(5) + ->and('first_name', 'Rahim') + ->and('last_name', 'Ullah') + ->or('gender', 'Male') + ->orderBy('DESC') + ->result(); +``` + +- [x] Using Static Classes: +```php +$admins = ObjectRelation::all() + ->sqlCode('admins') + ->whereValue(3) + ->and('isLogin', 'Yes') + ->or('isActive', 'Active') + ->orderBy() + ->result(); +``` +
+ +#### [Example of Non-Static Class](Eloquent.php) + +```bash +$ php Eloquent.php +``` + +```sql +SELECT * FROM users WHERE id = 5 AND first_name = "Rahim" OR gender = "Male" ORDER BY DESC +``` + +
+ +#### [Example of Static Class](ObjectRelation.php) + +```bash +$ php ObjectRelation.php +``` + +```sql +SELECT * FROM admins WHERE id = 3 AND isLogin = "Yes" OR isActive = "Active" ORDER BY ASC +``` diff --git a/OOP/Namespace/Downloader.php b/OOP/Namespace/Downloader.php new file mode 100644 index 0000000..5464e2b --- /dev/null +++ b/OOP/Namespace/Downloader.php @@ -0,0 +1,10 @@ + PHP Namespaces are the way of encapsulating items so that same names can be reused without name conflicts. + +### Why use Namespace? +Namespaces are qualifiers that solve two different problems: +- They allow for better organization by grouping classes that work together to perform a task +- They allow the same name to be used for more than one class + +### Usage and Restriction: +- A namespace must be declared the namespace at the top of the file before any other code. +- Namespaces are declared using the `namespace` keyword. +- You can import namespaces with the `use` keyword, thus avoiding the need to specify fully qualified names. +- Aliasing is similar to importing us `as` keyword, but it allows you to reference long namespaces by specifying a shorter name. + +### Syntax: +Define a Namespace: + +```php +namespace Library\Excel; +``` + +Example of Use Case No 01: + +```php +$app = new \Library\Excel\GenerateFile(); +``` + +Example of Use Case No 02: + +```php +use Library/Excel/GenerateFile; +$app = new GenerateFile(); +``` + +```php +use Library/Excel/GenerateFile as Excel; +$app = new Excel(); +``` + +
+ +#### [Example of Downloader Class:](Downloader.php) +```bash +$ php Downloader.php +``` + +```text +PDF file is downloaded successfully... +Excel file is downloaded successfully... +``` + diff --git a/OOP/Pagination/PaginationController.php b/OOP/Pagination/PaginationController.php new file mode 100644 index 0000000..57b81ff --- /dev/null +++ b/OOP/Pagination/PaginationController.php @@ -0,0 +1,53 @@ +dataArr = $data; + $this->limitOn = $limit; + $this->pageURL = $url; + $this->ulClass = $ulClass; + $this->liClass = $liClass; + $this->offsets = $this->currentPageNo(); + } + + public function currentPageNo() + { + $explode = explode('=', $this->pageURL); + if (isset($_GET[end($explode)])) { + $this->offsets = $_GET[end($explode)]; + } else { + $this->offsets = 1; + } + + return $this->offsets; + } + + +// public function paginate(): void +// { +// $this->pageName = trim($page); +// +// echo '
    '; +// for ($i = 0; $i < count($data); $i++) { +// echo '
  • '. $i.'
  • '; +// } +// echo '
'; +// } +} + +$arr = ['Apple', 'Banana', 'Mango', 'Lemon']; + +$obj = new PaginationController($arr, 3, 'users?page=2', 'list-items', 'list-item-inline'); +print_r($obj); diff --git a/OOP/Pagination/README.md b/OOP/Pagination/README.md new file mode 100644 index 0000000..9e96d53 --- /dev/null +++ b/OOP/Pagination/README.md @@ -0,0 +1,11 @@ + + +```php +$pageNo = 1; +$limits = 5; +$offset = ($pageNo - 1) * $limits; + +$index1 = $offset; +$index2 = $index1 + $limits; +$index3 = $index2 + $limits; +``` diff --git a/OOP/Polymorphism/Abstract/CelsiusToFahrenheit.php b/OOP/Polymorphism/Abstract/CelsiusToFahrenheit.php new file mode 100644 index 0000000..9655de7 --- /dev/null +++ b/OOP/Polymorphism/Abstract/CelsiusToFahrenheit.php @@ -0,0 +1,19 @@ +celsius = $celsius; + } + + public function calculate() + { + $calculate = $this->celsius * (9.0 / 5.0) + 32.0; + echo 'Temperature of °F: ' . $calculate . PHP_EOL; + } +} diff --git a/OOP/Polymorphism/Abstract/FahrenheitToCelsius.php b/OOP/Polymorphism/Abstract/FahrenheitToCelsius.php new file mode 100644 index 0000000..d94df9a --- /dev/null +++ b/OOP/Polymorphism/Abstract/FahrenheitToCelsius.php @@ -0,0 +1,19 @@ +fahrenheit = $fahrenheit; + } + + public function calculate() + { + $calculate = ($this->fahrenheit - 32.0) * 5.0 / 9.0; + echo 'Temperature of °C: ' . $calculate . PHP_EOL; + } +} diff --git a/OOP/Polymorphism/Abstract/Temperature.php b/OOP/Polymorphism/Abstract/Temperature.php new file mode 100644 index 0000000..0c8a445 --- /dev/null +++ b/OOP/Polymorphism/Abstract/Temperature.php @@ -0,0 +1,7 @@ +radius = $radius; + } + + public function area() + { + $calculate = pi() * $this->radius * $this->radius; + echo 'Area of circle: ' . sprintf('%.2f', $calculate) . PHP_EOL; + } +} diff --git a/OOP/Polymorphism/Interface/Rectangle.php b/OOP/Polymorphism/Interface/Rectangle.php new file mode 100644 index 0000000..29d6ba2 --- /dev/null +++ b/OOP/Polymorphism/Interface/Rectangle.php @@ -0,0 +1,21 @@ +length = $length; + $this->width = $width; + } + + public function area() + { + $calculate = $this->length * $this->width; + echo 'Area of rectangle: ' . sprintf('%.0f', $calculate) . PHP_EOL; + } +} diff --git a/OOP/Polymorphism/Interface/ShapeGenerate.php b/OOP/Polymorphism/Interface/ShapeGenerate.php new file mode 100644 index 0000000..313c344 --- /dev/null +++ b/OOP/Polymorphism/Interface/ShapeGenerate.php @@ -0,0 +1,6 @@ +base = $base; + $this->height = $height; + } + + public function area() + { + $calculate = ($this->base * $this->height) / 2; + echo 'Area of triangle: ' . sprintf('%.2f', $calculate) . PHP_EOL; + } +} diff --git a/OOP/Polymorphism/Polymorphism.php b/OOP/Polymorphism/Polymorphism.php new file mode 100644 index 0000000..70ca93a --- /dev/null +++ b/OOP/Polymorphism/Polymorphism.php @@ -0,0 +1,31 @@ +calculate(); + +$ftc = new FahrenheitToCelsius(98.6); +$ftc->calculate(); + + +// Example of Using Interface +$c= new Circle(20); +$c->area(); + +$r = new Rectangle(23, 18); +$r->area(); + +$t = new Triangle(15, 28.6); +$t->area(); diff --git a/OOP/Polymorphism/README.md b/OOP/Polymorphism/README.md new file mode 100644 index 0000000..acaaef1 --- /dev/null +++ b/OOP/Polymorphism/README.md @@ -0,0 +1,69 @@ +### What is PolyMorphism? + +--- + +- The PolyMorphism means **Many Forms**, in order to **Poly** stands for **Many** and **Morphism** stands for **Forms**. +- In OOP, It deals with functions with the same operations may be behaved differently in different class. +- It is implemented using the concept of method overloading and method overriding. +- In PHP method overloading is not supported directly. +- Polymorphism must be using **[Interface](Interface)** and/or **[Abstract Class](Abstract)** as well. +- It is used to make the program more elegant and easier to maintain and update. +- It uses a single function that perform different actions according to the different requirements. + +
+ +#### [Example of Polymorphism](Polymorphism.php) +```bash +$ php Polymorphism.php +``` +```php +[comment]: <> (Autoload Classes) + +spl_autoload_register(function ($class) { + if (file_exists('Abstract/' . $class . '.php')) { + require_once 'Abstract/' . $class . '.php'; + } + + if (file_exists('Interface/' . $class . '.php')) { + require_once 'Interface/' . $class . '.php'; + } +}); +``` +
+ +```php +[comment]: <> (Example of Using Abstract Class) + +$ctf = new CelsiusToFahrenheit(37); +$ctf->calculate(); + +$ftc = new FahrenheitToCelsius(98.6); +$ftc->calculate(); +``` +```text +[comment]: <> (Output Using Abstract Class) + +Temperature of °F: 98.6 +Temperature of °C: 37 +``` +
+ +```php +[comment]: <> (Example of Using Interface) + +$c= new Circle(20); +$c->area(); + +$r = new Rectangle(23, 18); +$r->area(); + +$t = new Triangle(15, 28.6); +$t->area(); +``` +```text +[comment]: <> (Output Using Interface) + +Area of circle: 1256.64 +Area of rectangle: 414 +Area of triangle: 214.50 +``` diff --git a/OOP/README.md b/OOP/README.md new file mode 100644 index 0000000..bf606f0 --- /dev/null +++ b/OOP/README.md @@ -0,0 +1,30 @@ +## What is OOP? + +> Object-Oriented is an approach to software development that models application around real world objects such as employees, cars, bank accounts, etc. A class defines the properties and methods of a real world object. As opposed to procedural programming where the focus is on writing procedures or functions that perform operations on the data, in object-oriented programming the focus is on the creations of objects which contain both data and functions together. + +> A class acts as a template or blueprint from which lots of individual objects can be created. When individual objects are created, they inherit the same generic properties and behaviors, although each object may have different values for certain properties. + +> For example, think of a class as a blueprint for a house. The blueprint itself is not a house, but is a detailed plan of the house. While, an object is like an actual house built according to that blueprint. We can build several identical houses from the same blueprint, but each house may have different paints, interiors and families inside, as shown in the illustration below. + +![Class Illustration](./../../assets/class-object-relationship-illustration.png) + +### Object-Oriented Concepts: +Before we go in detail, lets define important terms related to Object-Oriented Programming. +- [x] ```Class``` This is a programmer-defined data type, which includes local functions as well as local data. You can think of a class as a template for making many instances of the same kind (or class) of object. +- [x] ```Object``` An individual instance of the data structure defined by a class. You define a class once and then make many objects that belong to it. Objects are also known as instance. +- [x] ```Member Variable``` These are the variables defined inside a class. This data will be invisible to the outside of the class and can be accessed via member functions. These variables are called attribute of the object once an object is created. +- [x] ```Member function``` These are the function defined inside a class and are used to access object data. +- [x] ```Inheritance``` When a class is defined by inheriting existing function of a parent class then it is called inheritance. Here child class will inherit all or few member functions and variables of a parent class. +- [x] ```Parent class``` A class that is inherited from by another class. This is also called a base class or super class. +- [x] ```Child Class``` A class that inherits from another class. This is also called a subclass or derived class. +- [x] ```Polymorphism``` This is an object-oriented concept where same function can be used for different purposes. For example function name will remain same but it takes different number of arguments and can do different task. +- [x] ```Overloading``` a type of polymorphism in which some or all operators have different implementations depending on the types of their arguments. Similarly functions can also be overloaded with different implementation. +- [x] ```Data Abstraction``` Any representation of data in which the implementation details are hidden (abstracted). +- [x] ```Encapsulation``` refers to a concept where we encapsulate all the data and member functions together to form an object. +- [x] ```Constructor``` refers to a special type of function which will be called automatically whenever there is an object formation from a class. +- [x] ```Destructor``` refers to a special type of function which will be called automatically whenever an object is deleted or goes out of scope. + +### Define a Class: +A class is defined by using the class keyword, followed by the name of the class, and a pair of curly braces ```{ }```. All its properties and methods go inside the braces. + +Please see the basic example of [House](Basic/House.php) class... diff --git a/OOP/Static/BankAccount.php b/OOP/Static/BankAccount.php new file mode 100644 index 0000000..64a125a --- /dev/null +++ b/OOP/Static/BankAccount.php @@ -0,0 +1,28 @@ + self::$bankName, + 'account_holder' => self::$accountHolder, + 'account_no' => self::$accountNo, + 'expire_date' => self::$expireDate + ); + } +} + +$bank = new BankAccount(); +print_r($bank->bankDetails('Eastern Bank Limited', 'Mr. John Doe', '5454 752 986', '2024-07-15')); diff --git a/OOP/Static/Controllers/Profile.php b/OOP/Static/Controllers/Profile.php new file mode 100644 index 0000000..c06ed0a --- /dev/null +++ b/OOP/Static/Controllers/Profile.php @@ -0,0 +1,30 @@ + self::$fullName, + 'designation' => self::$designation, + 'department' => self::$department, + 'email_id' => self::$email, + 'mobile_no' => self::$mobile, + 'address' => self::$address + ); + } +} diff --git a/OOP/Static/Late Static Binding/ChildClass.php b/OOP/Static/Late Static Binding/ChildClass.php new file mode 100644 index 0000000..3d7277f --- /dev/null +++ b/OOP/Static/Late Static Binding/ChildClass.php @@ -0,0 +1,12 @@ +without creating an instance of the class first
. +- Static methods are declared with the `static` keyword: +- A class can have both static and non-static methods. +- To call a static method from a child class, use the `parent` keyword inside the child class +- The static method can be `public` or `protected` +- Static properties are accessed using the Scope Resolution Operator `(::)` and cannot be accessed through the object operator `(->)`. +- It's possible to reference the class using (`self`, `parent` and `static`) keywords. + +
+ +#### [Example of Student Profile Class:](TeacherProfile.php) + +```bash +$ php TeacherProfile.php +``` + +```php +Array +( + [full_name] => John Doe + [designation] => Guest Lecturer + [department] => English + [email_id] => johndoe@gmail.com + [mobile_no] => +880 1316-440504 + [address] => Dhaka-1206, Bangladesh +) +``` +
+ +#### [Example of Bank Account Class:](BankAccount.php) + +```bash +$ php BankAccount.php +``` + +```php +Array +( + [bank_name] => Eastern Bank Limited + [account_holder] => Mr. John Doe + [account_no] => 5454 752 986 + [expire_date] => 2024-07-15 +) +``` +
+ +#### [Example of Salary Statement Class:](SalaryStatement.php) + +```bash +$ php SalaryStatement.php +``` + +```php +Array +( + [bank_name] => Bank Asia Limited + [account_no] => 8745 5412 5451 + [basic_salary] => 6500 tk + [transport_allowance] => 780 tk + [dining_allowance] => 1170 tk + [provident_fund] => 650 tk + [total_salary] => 9100 tk +) +``` +
+ +#### [Example of Child Class:](ChildClass.php) + +```bash +$ php ChildClass.php +``` + +```text +John Doe +Kabir Khan +``` diff --git a/OOP/Static/SalaryStatement.php b/OOP/Static/SalaryStatement.php new file mode 100644 index 0000000..1672400 --- /dev/null +++ b/OOP/Static/SalaryStatement.php @@ -0,0 +1,41 @@ +bankName = $bank; + $this->accountNo = $accountNo; + $this->basicSalary = $basic; + $this->transportAllowance = (float) $this->basicSalary * 0.12; + $this->dinningAllowance = (float) $this->basicSalary * 0.18; + $this->providentFund = (float) $this->basicSalary * 0.10; + $this->totalSalary = (float) $this->basicSalary + $this->transportAllowance + $this->dinningAllowance + $this->providentFund; + + return array( + 'bank_name' => $this->bankName, + 'account_no' => $this->accountNo, + 'basic_salary' => $this->basicSalary . ' tk', + 'transport_allowance' => $this->transportAllowance . ' tk', + 'dining_allowance' => $this->dinningAllowance . ' tk', + 'provident_fund' => $this->providentFund . ' tk', + 'total_salary' => $this->totalSalary . ' tk', + ); + } + + public static function salarySheet($bank, $accountNo, $basic): array + { + return (new self)->generateSheet($bank, $accountNo, $basic); + } +} + +print_r(SalaryStatement::salarySheet('Bank Asia Limited', '8745 5412 5451', 6500)); diff --git a/OOP/Static/TeacherProfile.php b/OOP/Static/TeacherProfile.php new file mode 100644 index 0000000..d4f3825 --- /dev/null +++ b/OOP/Static/TeacherProfile.php @@ -0,0 +1,13 @@ +fullName = $name; + $this->classNo = $class; + $this->rollNo = $roll; + + return [ + 'full_name' => $this->fullName, + 'class_no' => $this->classNo, + 'roll_no' => $this->rollNo, + ]; + } + + public function parents($father, $mother, $contact, $address) { + $this->fatherName = $father; + $this->motherName = $mother; + $this->contact = $contact; + $this->address = $address; + + return [ + 'father_name' => $this->fatherName, + 'mother_name' => $this->motherName, + 'contact' => $this->contact, + 'address' => $this->address, + ]; + } +} + +class StudentInformation { + use Student; + + public function details($name, $class, $roll, $father, $mother, $contact, $address) { + return array( + 'student' => $this->student($name, $class, $roll), + 'parents' => $this->parents($father, $mother, $contact, $address), + ); + } +} + +$info = new StudentInformation; +$rahim = $info->details('Abdur Rahim', '4', '17', 'Md. Abdur Rahman', 'Karimunnessa', '+88 01645 770422', 'Dhaka-1206, Bangladesh'); + +print_r($rahim); + +/** + * The output of the code above will be: + * + * Array + * ( + * [student] => Array + * ( + * [fullname] => Abdur Rahim + * [class_no] => 4 + * [roll_no] => 17 + * ) + * [parents] => Array + * ( + * [father_name] => Md. Abdur Rahman + * [mother_name] => Karimunnessa + * [contact] => +88 01645 770422 + * [address] => Dhaka-1206, Bangladesh + * ) + * ) + * */ + + + + +// Example 02: +trait Shape { + public $length; + public $radius; + public $shape; + + public function area($area) { + echo $this->circle($area) . "\n" . $this->square($area) . "\n"; + } + + public function circle($radius) { + $this->radius = $radius; + $this->shape = pi() * pow($this->radius, 2); + + return "Area of circle is: " . sprintf('%.2f', $this->shape); + } + + public function square($length) { + $this->length = $length; + $this->shape = pow($this->length, 2); + + return "Area of square is: " . sprintf('%.0f', $this->shape); + } +} + +class ShapeGenerator { + public $length; + public $radius; + public $shape; + + public function area($area) { + echo $this->circle($area) . "\n" . $this->square($area) . "\n"; + } + + public function circle($radius) { + $this->radius = $radius; + $this->shape = pi() * pow($this->radius, 3); + + return "Area of circle is: " . sprintf('%.2f', $this->shape); + } + + public function square($length) { + $this->length = $length; + $this->shape = pow($this->length, 3); + + return "Area of square is: " . sprintf('%.0f', $this->shape); + } +} + +class DrawShape extends ShapeGenerator { + use ShapeGenerate; + + public function area($area) { + echo $this->circle($area) . "\n" . $this->square($area) . "\n"; + } + + public function circle($radius) { + $this->radius = $radius; + $this->shape = pi() * pow($this->radius, 4); + + return "Area of circle is: " . sprintf('%.2f', $this->shape); + } + + public function square($length) { + $this->length = $length; + $this->shape = pow($this->length, 4); + + return "Area of square is: " . sprintf('%.0f', $this->shape); + } +} + +$a = new DrawShape; +$a->area(30); + +/** + * The output of the code above will be: + * + * Area of circle is: 2827.43 + * Area of square is: 900 + * + * Note: The DrawShape class is used ShapeGenerate trait and also extended the + * ShapeGenerator class. So according to order precedence if DrawShape + * use same methods and/or properties then it will be overriding traits + * and parent class. But if DrawShape doesn't override traits or parent + * class then priority will be execute trait first. + * + * */ + + + +// Example 03: +trait SayHello { + public function index() { + echo "Hello"; + } +} + +trait SayWorld { + public function index() { + echo "World"; + } +} diff --git a/OOP/TypeHinting/Example1.php b/OOP/TypeHinting/Example1.php new file mode 100644 index 0000000..1c2752a --- /dev/null +++ b/OOP/TypeHinting/Example1.php @@ -0,0 +1,62 @@ + $name, + 'email' => $email, + 'mobile' => $mobile, + 'address' => $address, + ); + } + + public function examination(string $section, int $roll, int $examTerm): array{ + return array( + 'section' => $section, + 'roll_no' => $roll, + 'exam_term' => $examTerm, + ); + } +} + +// $request = new Request; +// $admission = $request->admission('Kabir Khan', 'kabirkhan@gmail.com', '+880 1316-440504', 'Dhaka-1206, Bangladesh'); +// $examination = $request->examination('Bangla', 12, 3); + +// print_r($admission); +// print_r($examination); + +class Student { + public $request; + + public function information(Request $request) :array + { + $this->request = $request; + return $request->admission('Kabir Khan', 'kabirkhan@gmail.com', '+880 1316-440504', 'Dhaka-1206, Bangladesh'); + } +} + +$request = new Request; +$kabir = new Student; + +print_r($kabir->information($request)); diff --git a/OOP/TypeHinting/Example2.php b/OOP/TypeHinting/Example2.php new file mode 100644 index 0000000..931b05d --- /dev/null +++ b/OOP/TypeHinting/Example2.php @@ -0,0 +1 @@ +Example2.php \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 0000000..b765c9a --- /dev/null +++ b/README.md @@ -0,0 +1,30 @@ +## PHP - HyperText PreProcessor + +PHP is a popular general-purpose scripting language that is especially suited to web development. Fast, flexible and pragmatic, PHP powers everything from your blog to the most popular websites in the world. + +- [Official](https://www.php.net/) +- [Wikipedia](https://en.wikipedia.org/wiki/PHP) + +![PHP Image](php.png) + + +## Resources +- DesignPattern + - [Documentation](https://designpatternsphp.readthedocs.io/en/latest/README.html) +- SolidPrinciple + - [Digital Occean](https://www.digitalocean.com/community/conceptual_articles/s-o-l-i-d-the-first-five-principles-of-object-oriented-design) +- Asynchronous in PHP + - [Spatie](https://github.com/spatie/async.git) +- PHP Unit Test + - [Repository](https://github.com/sebastianbergmann/phpunit.git) + - [Documentatioin](https://phpunit.readthedocs.io/en/9.5/) +- Environment Variables + - [vlucas](https://github.com/vlucas/phpdotenv.git) +- Mailing Libraries + - [Swift Mailer](https://swiftmailer.symfony.com/docs/introduction.html) + - [PHP Mailer](https://github.com/PHPMailer/PHPMailer) +- Database Backup + - [MySQL Dump](https://github.com/ifsnop/mysqldump-php) + - [DB Dumper](https://github.com/spatie/db-dumper) +- Debugger and Profiler + - [Xdebug](https://xdebug.org/) \ No newline at end of file diff --git a/REGEX/.gitignore b/REGEX/.gitignore new file mode 100644 index 0000000..723ef36 --- /dev/null +++ b/REGEX/.gitignore @@ -0,0 +1 @@ +.idea \ No newline at end of file diff --git a/REGEX/README.md b/REGEX/README.md new file mode 100644 index 0000000..189dc2c --- /dev/null +++ b/REGEX/README.md @@ -0,0 +1,97 @@ +### Shorthand Character Classes +These meta characters boast a pre-defined meaning and make various typical patterns easier to use. + +`/d/` matches any digit, short for `[0-9]` + +`/D/` matches non-digits, short for `[^0-9]` + +`/S/` matches non-white space character + +`/s/` matches any white space character + +`/w/` matches character, short for `[a-zA-Z_0-9]` + +`/W/` matches non-word character `[^w]` + +`/b/` Matches a word boundary where a word character is `[a-zA-Z0-9_]` + +
+ +### Matching Using Quantifiers +A quantifies helps developers to define how often an element occurs. + +`/X./` matches any character + +`/X*/` Matches zero or several repetitions of letter X, is short for `{0,}` + +`/X+-/` Matches one or more repetitions of letter X, is short for `{1,}` + +`/X?/` Finds now or exactly one letter X, is short for is short for `{0,1}` + +`// d{3}` matches three digits. `{}` describes the order of the preceding liberal + +`// d{1,4}` means d must occur at least once and at a maximum of four + +
+ +### Character Ranges +`/[a-z]/` matches all lowercase letters + +`/[A-Z]/` matches all uppercase letters + +`/[e-l]/` matches lowercase letters e to l (inclusive) + +`/[F-P]/` matches all uppercase letters F to P (inclusive) + +`/[0-9]/` matches all digits + +`/[5-9]/` matches any digit from 5 to 9 (inclusive) + +`/ [a-d1-7]/` matches a letter between a and d and figures from 1 to 7, but not d1 + +`/[a-zA-Z]/` matches all lowercase and uppercase letters + +`/[^a-zA-Z]/` matches non-letters + +
+ +### Matching Using Anchors +`/ ^The/` matches any string that starts with `The` + +`/ End$/` matches a string that ends with `End` + +`/ ^The End$/` exact string match starting with `“The”` and ending with `End` + +
+ +### Escape Characters +It is critical to note that escape characters are case-sensitive + +`/ a/` match a bell or alarm + +`/ e/` matches an escape + +`/ f/` matches a form feed + +`/ n/` matches a new line + +`/ Q…E/` ignores any special meanings in what is being matched + +`/ r/` matches a carriage return + +`/ v/` matches a vertical tab + +
+ +### Matching Using Flags +`/ i`/ ignores the case in pattern ( upper and lower case allowed) + +`/ m/` multi-line match + +`/ s/` match new lines + +`/ x/` allow spaces and comments + +`/ j/` duplicate group names allowed + +`/ U/` unready match diff --git a/REGEX/introduction.php b/REGEX/introduction.php new file mode 100644 index 0000000..e69de29 diff --git a/Server Config/.htaccess b/Server Config/.htaccess new file mode 100644 index 0000000..878f895 --- /dev/null +++ b/Server Config/.htaccess @@ -0,0 +1,179 @@ +RewriteEngine on +RewriteCond %{HTTP_HOST} ^yourwebsite\.in$ +RewriteRule ^/?$ “http\:\/\/www\.yourwebsite\.in\/” [R=301,L] +RewriteEngine on +RewriteBase / +RewriteCond %{HTTP_USER_AGENT} almaden [OR] +RewriteCond %{HTTP_USER_AGENT} ^Anarchie [OR] +RewriteCond %{HTTP_USER_AGENT} ^ASPSeek [OR] +RewriteCond %{HTTP_USER_AGENT} ^attach [OR] +RewriteCond %{HTTP_USER_AGENT} ^autoemailspider [OR] +RewriteCond %{HTTP_USER_AGENT} ^BackWeb [OR] +RewriteCond %{HTTP_USER_AGENT} ^Bandit [OR] +RewriteCond %{HTTP_USER_AGENT} ^BatchFTP [OR] +RewriteCond %{HTTP_USER_AGENT} ^BlackWidow [OR] +RewriteCond %{HTTP_USER_AGENT} ^Bot\ mailto: [OR] +RewriteCond %{HTTP_USER_AGENT} ^Buddy [OR] +RewriteCond %{HTTP_USER_AGENT} ^bumblebee [OR] +RewriteCond %{HTTP_USER_AGENT} ^CherryPicker [OR] +RewriteCond %{HTTP_USER_AGENT} ^ChinaClaw [OR] +RewriteCond %{HTTP_USER_AGENT} ^CICC [OR] +RewriteCond %{HTTP_USER_AGENT} ^Collector [OR] +RewriteCond %{HTTP_USER_AGENT} ^Copier [OR] +RewriteCond %{HTTP_USER_AGENT} ^Crescent [OR] +RewriteCond %{HTTP_USER_AGENT} ^Custo [OR] +RewriteCond %{HTTP_USER_AGENT} ^DA [OR] +RewriteCond %{HTTP_USER_AGENT} ^DIIbot [OR] +RewriteCond %{HTTP_USER_AGENT} ^DISCo [OR] +RewriteCond %{HTTP_USER_AGENT} ^DISCo\ Pump [OR] +RewriteCond %{HTTP_USER_AGENT} ^Download\ Demon [OR] +RewriteCond %{HTTP_USER_AGENT} ^Download\ Wonder [OR] +RewriteCond %{HTTP_USER_AGENT} ^Downloader [OR] +RewriteCond %{HTTP_USER_AGENT} ^Drip [OR] +RewriteCond %{HTTP_USER_AGENT} ^DSurf15a [OR] +RewriteCond %{HTTP_USER_AGENT} ^eCatch [OR] +RewriteCond %{HTTP_USER_AGENT} ^EasyDL/2.99 [OR] +RewriteCond %{HTTP_USER_AGENT} ^EirGrabber [OR] +RewriteCond %{HTTP_USER_AGENT} email [NC,OR] +RewriteCond %{HTTP_USER_AGENT} ^EmailCollector [OR] +RewriteCond %{HTTP_USER_AGENT} ^EmailSiphon [OR] +RewriteCond %{HTTP_USER_AGENT} ^EmailWolf [OR] +RewriteCond %{HTTP_USER_AGENT} ^Express\ WebPictures [OR] +RewriteCond %{HTTP_USER_AGENT} ^ExtractorPro [OR] +RewriteCond %{HTTP_USER_AGENT} ^EyeNetIE [OR] +RewriteCond %{HTTP_USER_AGENT} ^FileHound [OR] +RewriteCond %{HTTP_USER_AGENT} ^FlashGet [OR] +RewriteCond %{HTTP_USER_AGENT} FrontPage [NC,OR] +RewriteCond %{HTTP_USER_AGENT} ^GetRight [OR] +RewriteCond %{HTTP_USER_AGENT} ^GetSmart [OR] +RewriteCond %{HTTP_USER_AGENT} ^GetWeb! [OR] +RewriteCond %{HTTP_USER_AGENT} ^gigabaz [OR] +RewriteCond %{HTTP_USER_AGENT} ^Go\!Zilla [OR] +RewriteCond %{HTTP_USER_AGENT} ^Go!Zilla [OR] +RewriteCond %{HTTP_USER_AGENT} ^Go-Ahead-Got-It [OR] +RewriteCond %{HTTP_USER_AGENT} ^gotit [OR] +RewriteCond %{HTTP_USER_AGENT} ^Grabber [OR] +RewriteCond %{HTTP_USER_AGENT} ^GrabNet [OR] +RewriteCond %{HTTP_USER_AGENT} ^Grafula [OR] +RewriteCond %{HTTP_USER_AGENT} ^grub-client [OR] +RewriteCond %{HTTP_USER_AGENT} ^HMView [OR] +RewriteCond %{HTTP_USER_AGENT} ^HTTrack [OR] +RewriteCond %{HTTP_USER_AGENT} ^httpdown [OR] +RewriteCond %{HTTP_USER_AGENT} .httrack. [NC,OR] +RewriteCond %{HTTP_USER_AGENT} ^ia_archiver [OR] +RewriteCond %{HTTP_USER_AGENT} ^Image\ Stripper [OR] +RewriteCond %{HTTP_USER_AGENT} ^Image\ Sucker [OR] +RewriteCond %{HTTP_USER_AGENT} ^Indy*Library [OR] +RewriteCond %{HTTP_USER_AGENT} Indy\ Library [NC,OR] +RewriteCond %{HTTP_USER_AGENT} ^InterGET [OR] +RewriteCond %{HTTP_USER_AGENT} ^InternetLinkagent [OR] +RewriteCond %{HTTP_USER_AGENT} ^Internet\ Ninja [OR] +RewriteCond %{HTTP_USER_AGENT} ^InternetSeer.com [OR] +RewriteCond %{HTTP_USER_AGENT} ^Iria [OR] +RewriteCond %{HTTP_USER_AGENT} ^JBH*agent [OR] +RewriteCond %{HTTP_USER_AGENT} ^JetCar [OR] +RewriteCond %{HTTP_USER_AGENT} ^JOC\ Web\ Spider [OR] +RewriteCond %{HTTP_USER_AGENT} ^JustView [OR] +RewriteCond %{HTTP_USER_AGENT} ^larbin [OR] +RewriteCond %{HTTP_USER_AGENT} ^LeechFTP [OR] +RewriteCond %{HTTP_USER_AGENT} ^LexiBot [OR] +RewriteCond %{HTTP_USER_AGENT} ^lftp [OR] +RewriteCond %{HTTP_USER_AGENT} ^Link*Sleuth [OR] +RewriteCond %{HTTP_USER_AGENT} ^likse [OR] +RewriteCond %{HTTP_USER_AGENT} ^Link [OR] +RewriteCond %{HTTP_USER_AGENT} ^LinkWalker [OR] +RewriteCond %{HTTP_USER_AGENT} ^Mag-Net [OR] +RewriteCond %{HTTP_USER_AGENT} ^Magnet [OR] +RewriteCond %{HTTP_USER_AGENT} ^Mass\ Downloader [OR] +RewriteCond %{HTTP_USER_AGENT} ^Memo [OR] +RewriteCond %{HTTP_USER_AGENT} ^Microsoft.URL [OR] +RewriteCond %{HTTP_USER_AGENT} ^MIDown\ tool [OR] +RewriteCond %{HTTP_USER_AGENT} ^Mirror [OR] +RewriteCond %{HTTP_USER_AGENT} ^Mister\ PiX [OR] +RewriteCond %{HTTP_USER_AGENT} ^Mozilla.*Indy [OR] +RewriteCond %{HTTP_USER_AGENT} ^Mozilla.*NEWT [OR] +RewriteCond %{HTTP_USER_AGENT} ^Mozilla*MSIECrawler [OR] +RewriteCond %{HTTP_USER_AGENT} ^MS\ FrontPage* [OR] +RewriteCond %{HTTP_USER_AGENT} ^MSFrontPage [OR] +RewriteCond %{HTTP_USER_AGENT} ^MSIECrawler [OR] +RewriteCond %{HTTP_USER_AGENT} ^MSProxy [OR] +RewriteCond %{HTTP_USER_AGENT} ^Navroad [OR] +RewriteCond %{HTTP_USER_AGENT} ^NearSite [OR] +RewriteCond %{HTTP_USER_AGENT} ^NetAnts [OR] +RewriteCond %{HTTP_USER_AGENT} ^NetMechanic [OR] +RewriteCond %{HTTP_USER_AGENT} ^NetSpider [OR] +RewriteCond %{HTTP_USER_AGENT} ^Net\ Vampire [OR] +RewriteCond %{HTTP_USER_AGENT} ^NetZIP [OR] +RewriteCond %{HTTP_USER_AGENT} ^NICErsPRO [OR] +RewriteCond %{HTTP_USER_AGENT} ^Ninja [OR] +RewriteCond %{HTTP_USER_AGENT} ^Octopus [OR] +RewriteCond %{HTTP_USER_AGENT} ^Offline\ Explorer [OR] +RewriteCond %{HTTP_USER_AGENT} ^Offline\ Navigator [OR] +RewriteCond %{HTTP_USER_AGENT} ^Openfind [OR] +RewriteCond %{HTTP_USER_AGENT} ^PageGrabber [OR] +RewriteCond %{HTTP_USER_AGENT} ^Papa\ Foto [OR] +RewriteCond %{HTTP_USER_AGENT} ^pavuk [OR] +RewriteCond %{HTTP_USER_AGENT} ^pcBrowser [OR] +RewriteCond %{HTTP_USER_AGENT} ^Ping [OR] +RewriteCond %{HTTP_USER_AGENT} ^PingALink [OR] +RewriteCond %{HTTP_USER_AGENT} ^Pockey [OR] +RewriteCond %{HTTP_USER_AGENT} ^psbot [OR] +RewriteCond %{HTTP_USER_AGENT} ^Pump [OR] +RewriteCond %{HTTP_USER_AGENT} ^QRVA [OR] +RewriteCond %{HTTP_USER_AGENT} ^RealDownload [OR] +RewriteCond %{HTTP_USER_AGENT} ^Reaper [OR] +RewriteCond %{HTTP_USER_AGENT} ^Recorder [OR] +RewriteCond %{HTTP_USER_AGENT} ^ReGet [OR] +RewriteCond %{HTTP_USER_AGENT} ^Scooter [OR] +RewriteCond %{HTTP_USER_AGENT} ^Seeker [OR] +RewriteCond %{HTTP_USER_AGENT} ^Siphon [OR] +RewriteCond %{HTTP_USER_AGENT} ^SiteSnagger [OR] +RewriteCond %{HTTP_USER_AGENT} ^SlySearch [OR] +RewriteCond %{HTTP_USER_AGENT} ^SmartDownload [OR] +RewriteCond %{HTTP_USER_AGENT} ^Snake [OR] +RewriteCond %{HTTP_USER_AGENT} ^SpaceBison [OR] +RewriteCond %{HTTP_USER_AGENT} ^sproose [OR] +RewriteCond %{HTTP_USER_AGENT} ^Stripper [OR] +RewriteCond %{HTTP_USER_AGENT} ^Sucker [OR] +RewriteCond %{HTTP_USER_AGENT} ^SuperBot [OR] +RewriteCond %{HTTP_USER_AGENT} ^SuperHTTP [OR] +RewriteCond %{HTTP_USER_AGENT} ^Surfbot [OR] +RewriteCond %{HTTP_USER_AGENT} ^Szukacz [OR] +RewriteCond %{HTTP_USER_AGENT} ^tAkeOut [OR] +RewriteCond %{HTTP_USER_AGENT} ^Teleport\ Pro [OR] +RewriteCond %{HTTP_USER_AGENT} ^URLSpiderPro [OR] +RewriteCond %{HTTP_USER_AGENT} ^Vacuum [OR] +RewriteCond %{HTTP_USER_AGENT} ^VoidEYE [OR] +RewriteCond %{HTTP_USER_AGENT} ^Web\ Image\ Collector [OR] +RewriteCond %{HTTP_USER_AGENT} ^Web\ Sucker [OR] +RewriteCond %{HTTP_USER_AGENT} ^WebAuto [OR] +RewriteCond %{HTTP_USER_AGENT} ^[Ww]eb[Bb]andit [OR] +RewriteCond %{HTTP_USER_AGENT} ^webcollage [OR] +RewriteCond %{HTTP_USER_AGENT} ^WebCopier [OR] +RewriteCond %{HTTP_USER_AGENT} ^Web\ Downloader [OR] +RewriteCond %{HTTP_USER_AGENT} ^WebEMailExtrac.* [OR] +RewriteCond %{HTTP_USER_AGENT} ^WebFetch [OR] +RewriteCond %{HTTP_USER_AGENT} ^WebGo\ IS [OR] +RewriteCond %{HTTP_USER_AGENT} ^WebHook [OR] +RewriteCond %{HTTP_USER_AGENT} ^WebLeacher [OR] +RewriteCond %{HTTP_USER_AGENT} ^WebMiner [OR] +RewriteCond %{HTTP_USER_AGENT} ^WebMirror [OR] +RewriteCond %{HTTP_USER_AGENT} ^WebReaper [OR] +RewriteCond %{HTTP_USER_AGENT} ^WebSauger [OR] +RewriteCond %{HTTP_USER_AGENT} ^Website [OR] +RewriteCond %{HTTP_USER_AGENT} ^Website\ eXtractor [OR] +RewriteCond %{HTTP_USER_AGENT} ^Website\ Quester [OR] +RewriteCond %{HTTP_USER_AGENT} ^Webster [OR] +RewriteCond %{HTTP_USER_AGENT} ^WebStripper [OR] +RewriteCond %{HTTP_USER_AGENT} WebWhacker [OR] +RewriteCond %{HTTP_USER_AGENT} ^WebZIP [OR] +RewriteCond %{HTTP_USER_AGENT} ^Wget [OR] +RewriteCond %{HTTP_USER_AGENT} ^Whacker [OR] +RewriteCond %{HTTP_USER_AGENT} ^Widow [OR] +RewriteCond %{HTTP_USER_AGENT} ^WWWOFFLE [OR] +RewriteCond %{HTTP_USER_AGENT} ^x-Tractor [OR] +RewriteCond %{HTTP_USER_AGENT} ^Xaldon\ WebSpider [OR] +RewriteCond %{HTTP_USER_AGENT} ^Xenu [OR] +RewriteCond %{HTTP_USER_AGENT} ^Zeus.*Webster [OR] +RewriteCond %{HTTP_USER_AGENT} ^Zeus +RewriteRule ^.* – [F,L] diff --git a/Server Config/PreventWebsiteCopier.php b/Server Config/PreventWebsiteCopier.php new file mode 100644 index 0000000..878f895 --- /dev/null +++ b/Server Config/PreventWebsiteCopier.php @@ -0,0 +1,179 @@ +RewriteEngine on +RewriteCond %{HTTP_HOST} ^yourwebsite\.in$ +RewriteRule ^/?$ “http\:\/\/www\.yourwebsite\.in\/” [R=301,L] +RewriteEngine on +RewriteBase / +RewriteCond %{HTTP_USER_AGENT} almaden [OR] +RewriteCond %{HTTP_USER_AGENT} ^Anarchie [OR] +RewriteCond %{HTTP_USER_AGENT} ^ASPSeek [OR] +RewriteCond %{HTTP_USER_AGENT} ^attach [OR] +RewriteCond %{HTTP_USER_AGENT} ^autoemailspider [OR] +RewriteCond %{HTTP_USER_AGENT} ^BackWeb [OR] +RewriteCond %{HTTP_USER_AGENT} ^Bandit [OR] +RewriteCond %{HTTP_USER_AGENT} ^BatchFTP [OR] +RewriteCond %{HTTP_USER_AGENT} ^BlackWidow [OR] +RewriteCond %{HTTP_USER_AGENT} ^Bot\ mailto: [OR] +RewriteCond %{HTTP_USER_AGENT} ^Buddy [OR] +RewriteCond %{HTTP_USER_AGENT} ^bumblebee [OR] +RewriteCond %{HTTP_USER_AGENT} ^CherryPicker [OR] +RewriteCond %{HTTP_USER_AGENT} ^ChinaClaw [OR] +RewriteCond %{HTTP_USER_AGENT} ^CICC [OR] +RewriteCond %{HTTP_USER_AGENT} ^Collector [OR] +RewriteCond %{HTTP_USER_AGENT} ^Copier [OR] +RewriteCond %{HTTP_USER_AGENT} ^Crescent [OR] +RewriteCond %{HTTP_USER_AGENT} ^Custo [OR] +RewriteCond %{HTTP_USER_AGENT} ^DA [OR] +RewriteCond %{HTTP_USER_AGENT} ^DIIbot [OR] +RewriteCond %{HTTP_USER_AGENT} ^DISCo [OR] +RewriteCond %{HTTP_USER_AGENT} ^DISCo\ Pump [OR] +RewriteCond %{HTTP_USER_AGENT} ^Download\ Demon [OR] +RewriteCond %{HTTP_USER_AGENT} ^Download\ Wonder [OR] +RewriteCond %{HTTP_USER_AGENT} ^Downloader [OR] +RewriteCond %{HTTP_USER_AGENT} ^Drip [OR] +RewriteCond %{HTTP_USER_AGENT} ^DSurf15a [OR] +RewriteCond %{HTTP_USER_AGENT} ^eCatch [OR] +RewriteCond %{HTTP_USER_AGENT} ^EasyDL/2.99 [OR] +RewriteCond %{HTTP_USER_AGENT} ^EirGrabber [OR] +RewriteCond %{HTTP_USER_AGENT} email [NC,OR] +RewriteCond %{HTTP_USER_AGENT} ^EmailCollector [OR] +RewriteCond %{HTTP_USER_AGENT} ^EmailSiphon [OR] +RewriteCond %{HTTP_USER_AGENT} ^EmailWolf [OR] +RewriteCond %{HTTP_USER_AGENT} ^Express\ WebPictures [OR] +RewriteCond %{HTTP_USER_AGENT} ^ExtractorPro [OR] +RewriteCond %{HTTP_USER_AGENT} ^EyeNetIE [OR] +RewriteCond %{HTTP_USER_AGENT} ^FileHound [OR] +RewriteCond %{HTTP_USER_AGENT} ^FlashGet [OR] +RewriteCond %{HTTP_USER_AGENT} FrontPage [NC,OR] +RewriteCond %{HTTP_USER_AGENT} ^GetRight [OR] +RewriteCond %{HTTP_USER_AGENT} ^GetSmart [OR] +RewriteCond %{HTTP_USER_AGENT} ^GetWeb! [OR] +RewriteCond %{HTTP_USER_AGENT} ^gigabaz [OR] +RewriteCond %{HTTP_USER_AGENT} ^Go\!Zilla [OR] +RewriteCond %{HTTP_USER_AGENT} ^Go!Zilla [OR] +RewriteCond %{HTTP_USER_AGENT} ^Go-Ahead-Got-It [OR] +RewriteCond %{HTTP_USER_AGENT} ^gotit [OR] +RewriteCond %{HTTP_USER_AGENT} ^Grabber [OR] +RewriteCond %{HTTP_USER_AGENT} ^GrabNet [OR] +RewriteCond %{HTTP_USER_AGENT} ^Grafula [OR] +RewriteCond %{HTTP_USER_AGENT} ^grub-client [OR] +RewriteCond %{HTTP_USER_AGENT} ^HMView [OR] +RewriteCond %{HTTP_USER_AGENT} ^HTTrack [OR] +RewriteCond %{HTTP_USER_AGENT} ^httpdown [OR] +RewriteCond %{HTTP_USER_AGENT} .httrack. [NC,OR] +RewriteCond %{HTTP_USER_AGENT} ^ia_archiver [OR] +RewriteCond %{HTTP_USER_AGENT} ^Image\ Stripper [OR] +RewriteCond %{HTTP_USER_AGENT} ^Image\ Sucker [OR] +RewriteCond %{HTTP_USER_AGENT} ^Indy*Library [OR] +RewriteCond %{HTTP_USER_AGENT} Indy\ Library [NC,OR] +RewriteCond %{HTTP_USER_AGENT} ^InterGET [OR] +RewriteCond %{HTTP_USER_AGENT} ^InternetLinkagent [OR] +RewriteCond %{HTTP_USER_AGENT} ^Internet\ Ninja [OR] +RewriteCond %{HTTP_USER_AGENT} ^InternetSeer.com [OR] +RewriteCond %{HTTP_USER_AGENT} ^Iria [OR] +RewriteCond %{HTTP_USER_AGENT} ^JBH*agent [OR] +RewriteCond %{HTTP_USER_AGENT} ^JetCar [OR] +RewriteCond %{HTTP_USER_AGENT} ^JOC\ Web\ Spider [OR] +RewriteCond %{HTTP_USER_AGENT} ^JustView [OR] +RewriteCond %{HTTP_USER_AGENT} ^larbin [OR] +RewriteCond %{HTTP_USER_AGENT} ^LeechFTP [OR] +RewriteCond %{HTTP_USER_AGENT} ^LexiBot [OR] +RewriteCond %{HTTP_USER_AGENT} ^lftp [OR] +RewriteCond %{HTTP_USER_AGENT} ^Link*Sleuth [OR] +RewriteCond %{HTTP_USER_AGENT} ^likse [OR] +RewriteCond %{HTTP_USER_AGENT} ^Link [OR] +RewriteCond %{HTTP_USER_AGENT} ^LinkWalker [OR] +RewriteCond %{HTTP_USER_AGENT} ^Mag-Net [OR] +RewriteCond %{HTTP_USER_AGENT} ^Magnet [OR] +RewriteCond %{HTTP_USER_AGENT} ^Mass\ Downloader [OR] +RewriteCond %{HTTP_USER_AGENT} ^Memo [OR] +RewriteCond %{HTTP_USER_AGENT} ^Microsoft.URL [OR] +RewriteCond %{HTTP_USER_AGENT} ^MIDown\ tool [OR] +RewriteCond %{HTTP_USER_AGENT} ^Mirror [OR] +RewriteCond %{HTTP_USER_AGENT} ^Mister\ PiX [OR] +RewriteCond %{HTTP_USER_AGENT} ^Mozilla.*Indy [OR] +RewriteCond %{HTTP_USER_AGENT} ^Mozilla.*NEWT [OR] +RewriteCond %{HTTP_USER_AGENT} ^Mozilla*MSIECrawler [OR] +RewriteCond %{HTTP_USER_AGENT} ^MS\ FrontPage* [OR] +RewriteCond %{HTTP_USER_AGENT} ^MSFrontPage [OR] +RewriteCond %{HTTP_USER_AGENT} ^MSIECrawler [OR] +RewriteCond %{HTTP_USER_AGENT} ^MSProxy [OR] +RewriteCond %{HTTP_USER_AGENT} ^Navroad [OR] +RewriteCond %{HTTP_USER_AGENT} ^NearSite [OR] +RewriteCond %{HTTP_USER_AGENT} ^NetAnts [OR] +RewriteCond %{HTTP_USER_AGENT} ^NetMechanic [OR] +RewriteCond %{HTTP_USER_AGENT} ^NetSpider [OR] +RewriteCond %{HTTP_USER_AGENT} ^Net\ Vampire [OR] +RewriteCond %{HTTP_USER_AGENT} ^NetZIP [OR] +RewriteCond %{HTTP_USER_AGENT} ^NICErsPRO [OR] +RewriteCond %{HTTP_USER_AGENT} ^Ninja [OR] +RewriteCond %{HTTP_USER_AGENT} ^Octopus [OR] +RewriteCond %{HTTP_USER_AGENT} ^Offline\ Explorer [OR] +RewriteCond %{HTTP_USER_AGENT} ^Offline\ Navigator [OR] +RewriteCond %{HTTP_USER_AGENT} ^Openfind [OR] +RewriteCond %{HTTP_USER_AGENT} ^PageGrabber [OR] +RewriteCond %{HTTP_USER_AGENT} ^Papa\ Foto [OR] +RewriteCond %{HTTP_USER_AGENT} ^pavuk [OR] +RewriteCond %{HTTP_USER_AGENT} ^pcBrowser [OR] +RewriteCond %{HTTP_USER_AGENT} ^Ping [OR] +RewriteCond %{HTTP_USER_AGENT} ^PingALink [OR] +RewriteCond %{HTTP_USER_AGENT} ^Pockey [OR] +RewriteCond %{HTTP_USER_AGENT} ^psbot [OR] +RewriteCond %{HTTP_USER_AGENT} ^Pump [OR] +RewriteCond %{HTTP_USER_AGENT} ^QRVA [OR] +RewriteCond %{HTTP_USER_AGENT} ^RealDownload [OR] +RewriteCond %{HTTP_USER_AGENT} ^Reaper [OR] +RewriteCond %{HTTP_USER_AGENT} ^Recorder [OR] +RewriteCond %{HTTP_USER_AGENT} ^ReGet [OR] +RewriteCond %{HTTP_USER_AGENT} ^Scooter [OR] +RewriteCond %{HTTP_USER_AGENT} ^Seeker [OR] +RewriteCond %{HTTP_USER_AGENT} ^Siphon [OR] +RewriteCond %{HTTP_USER_AGENT} ^SiteSnagger [OR] +RewriteCond %{HTTP_USER_AGENT} ^SlySearch [OR] +RewriteCond %{HTTP_USER_AGENT} ^SmartDownload [OR] +RewriteCond %{HTTP_USER_AGENT} ^Snake [OR] +RewriteCond %{HTTP_USER_AGENT} ^SpaceBison [OR] +RewriteCond %{HTTP_USER_AGENT} ^sproose [OR] +RewriteCond %{HTTP_USER_AGENT} ^Stripper [OR] +RewriteCond %{HTTP_USER_AGENT} ^Sucker [OR] +RewriteCond %{HTTP_USER_AGENT} ^SuperBot [OR] +RewriteCond %{HTTP_USER_AGENT} ^SuperHTTP [OR] +RewriteCond %{HTTP_USER_AGENT} ^Surfbot [OR] +RewriteCond %{HTTP_USER_AGENT} ^Szukacz [OR] +RewriteCond %{HTTP_USER_AGENT} ^tAkeOut [OR] +RewriteCond %{HTTP_USER_AGENT} ^Teleport\ Pro [OR] +RewriteCond %{HTTP_USER_AGENT} ^URLSpiderPro [OR] +RewriteCond %{HTTP_USER_AGENT} ^Vacuum [OR] +RewriteCond %{HTTP_USER_AGENT} ^VoidEYE [OR] +RewriteCond %{HTTP_USER_AGENT} ^Web\ Image\ Collector [OR] +RewriteCond %{HTTP_USER_AGENT} ^Web\ Sucker [OR] +RewriteCond %{HTTP_USER_AGENT} ^WebAuto [OR] +RewriteCond %{HTTP_USER_AGENT} ^[Ww]eb[Bb]andit [OR] +RewriteCond %{HTTP_USER_AGENT} ^webcollage [OR] +RewriteCond %{HTTP_USER_AGENT} ^WebCopier [OR] +RewriteCond %{HTTP_USER_AGENT} ^Web\ Downloader [OR] +RewriteCond %{HTTP_USER_AGENT} ^WebEMailExtrac.* [OR] +RewriteCond %{HTTP_USER_AGENT} ^WebFetch [OR] +RewriteCond %{HTTP_USER_AGENT} ^WebGo\ IS [OR] +RewriteCond %{HTTP_USER_AGENT} ^WebHook [OR] +RewriteCond %{HTTP_USER_AGENT} ^WebLeacher [OR] +RewriteCond %{HTTP_USER_AGENT} ^WebMiner [OR] +RewriteCond %{HTTP_USER_AGENT} ^WebMirror [OR] +RewriteCond %{HTTP_USER_AGENT} ^WebReaper [OR] +RewriteCond %{HTTP_USER_AGENT} ^WebSauger [OR] +RewriteCond %{HTTP_USER_AGENT} ^Website [OR] +RewriteCond %{HTTP_USER_AGENT} ^Website\ eXtractor [OR] +RewriteCond %{HTTP_USER_AGENT} ^Website\ Quester [OR] +RewriteCond %{HTTP_USER_AGENT} ^Webster [OR] +RewriteCond %{HTTP_USER_AGENT} ^WebStripper [OR] +RewriteCond %{HTTP_USER_AGENT} WebWhacker [OR] +RewriteCond %{HTTP_USER_AGENT} ^WebZIP [OR] +RewriteCond %{HTTP_USER_AGENT} ^Wget [OR] +RewriteCond %{HTTP_USER_AGENT} ^Whacker [OR] +RewriteCond %{HTTP_USER_AGENT} ^Widow [OR] +RewriteCond %{HTTP_USER_AGENT} ^WWWOFFLE [OR] +RewriteCond %{HTTP_USER_AGENT} ^x-Tractor [OR] +RewriteCond %{HTTP_USER_AGENT} ^Xaldon\ WebSpider [OR] +RewriteCond %{HTTP_USER_AGENT} ^Xenu [OR] +RewriteCond %{HTTP_USER_AGENT} ^Zeus.*Webster [OR] +RewriteCond %{HTTP_USER_AGENT} ^Zeus +RewriteRule ^.* – [F,L] diff --git a/Session/.gitignore b/Session/.gitignore new file mode 100644 index 0000000..723ef36 --- /dev/null +++ b/Session/.gitignore @@ -0,0 +1 @@ +.idea \ No newline at end of file diff --git a/Session/.htaccess b/Session/.htaccess new file mode 100644 index 0000000..57b6e6f --- /dev/null +++ b/Session/.htaccess @@ -0,0 +1,2 @@ +RewriteEngine On +RewriteRule ^([^/]+)/? index.php?url=$1 [L,QSA] \ No newline at end of file diff --git a/Session/README.md b/Session/README.md new file mode 100644 index 0000000..e69de29 diff --git a/Session/index.php b/Session/index.php new file mode 100644 index 0000000..173cbec --- /dev/null +++ b/Session/index.php @@ -0,0 +1,88 @@ + + + + + + + <?php echo 'Learn PHP ' . str_replace('.19', '+', phpversion()); ?> + + + + + + + + +
+
PHP Session
+
+
+ +
+
+

Session Information

+ 'Jhon Doe', + 'email' => 'jhondoe@gmail.com', + 'address' => 'Dhaka-1206, Bangladesh' + ]; + + if (isset($_SESSION['user'])) : + echo '
Congratulation! Session is create successfully
'; + else : + echo '
Hurrah! Session is created already
'; + endif; + elseif ($_GET['url'] === 'check') : + + //Checkout Session + session_start(); + + if (isset($_SESSION['user'])) : + echo '
    '; + echo '
  • + Name: '. $_SESSION['user']['name'] .' +
  • '; + echo '
  • + Email: '. $_SESSION['user']['email'] .' +
  • '; + echo '
  • + Address: '. $_SESSION['user']['address'] .' +
  • '; + echo '
'; + else : + echo '
Oops! Session is not set yet
'; + endif; + elseif ($_GET['url'] === 'destroy') : + + //Destroy Session + session_start(); + session_destroy(); + + if (!empty($_SESSION['user'])) : + echo '
Congratulation! Session is delete successfully
'; + else : + echo '
Oops! Session is alreday deleted
'; + endif; + endif; + ?> +
+
+
+
+ + \ No newline at end of file diff --git a/Session/session.txt b/Session/session.txt new file mode 100644 index 0000000..c994ac9 --- /dev/null +++ b/Session/session.txt @@ -0,0 +1,20 @@ +Defination and Usage: +------------------------------------------------------------------------- + A session is a way to store information (in variables) to be used across +multiple pages. Unlike a cookie, the information is not stored on the users +computer. By default, session variables last until the user closes the browser. + + +Syntax: +------------------------------------------------------------------------- +create => + session_start(); + $_SESSION['session_key'] = 'session value here..'; + +checkout => + session_start(); + $_SESSION['session_key']; + +destroy => + session_start(); + session_destroy(); \ No newline at end of file diff --git a/Solid Principle/.gitignore b/Solid Principle/.gitignore new file mode 100644 index 0000000..723ef36 --- /dev/null +++ b/Solid Principle/.gitignore @@ -0,0 +1 @@ +.idea \ No newline at end of file diff --git a/Solid Principle/README.md b/Solid Principle/README.md new file mode 100644 index 0000000..e84c281 --- /dev/null +++ b/Solid Principle/README.md @@ -0,0 +1,114 @@ +## What is SOLID Principle? +SOLID is an acronym for 5 important design principle when doing OOP (Object-Oriented Programming). These 5 principles were introduced by `Robert C.Martin (Uncle Bob)` in his 2000 paper Design Principles and Design Patterns. The actual S.O.L.I.D acronym was, however identified later by `Micheal Feathers`. + +```text +S = Single Responsibility Principle +O = Open Closed Principle +L = Liskov Substitution Principle +I = Interface Segregation Principle +D = Dependency Inversion Principle +``` +
+ +#### [The Single Responsibility Principle](single-responsibility) +A class should have one and only one reason to change. +- Makes the class easier to maintain +- Potentially makes class reusable +- Easier to test +```bash +php index.php +``` +```php +use App\SingleResponsibility as SRP; + +// TODO: Example (Bad Design Pattern) No 01: +$shape = new SRP\ShapeCalculator(); +$shape->areaOfSquare(15); +$shape->areaOfCircle(20); +$shape->areaOfTriangle(15, 2); + + +// TODO: Example (Bad Design Pattern) No 02: +$staff = new SRP\SalaryGenerator('John Doe', 'Software Developer', 'ABC Private Co. Ltd.', '15000'); +print_r($staff->salarySheet()); + + +// TODO: Example (Good Design Pattern) No 03: +$square = new SRP\Square(20); +$circle = new SRP\Circle(15); +$tangle = new SRP\Triangle(8, 2); + +$area = new SRP\AreaCalculator($square, $circle, $tangle); +$area->shapeGenerate(); + + +// TODO: Example (Good Design Pattern) No 04: +$rashid = new SRP\Employee('Md. Abdur Rashid', 'Professional Graphics Designer', 'XYZ Internation Limited'); +$salary = new SRP\Payroll(6500); + +$hrm = new SRP\HumanResource($rashid, $salary); +print_r($hrm->statement()); +``` +
+ +#### [The Open Closed Principle](open-closed) +Object or entities should be Open for extension and Closed for modification +```bash +php index.php +``` +```php +use App\OpenClosed as OC; + +$square = new OC\Square(20); +$circle = new OC\Circle(15); +$tangle = new OC\Triangle(8, 12); + +$shapes = new OC\ShapeGenerator($square); +$shapes->run(); +``` +
+ +#### [The Liskov Substitution Principle](liskov-substitution) +In a computer program, if S is a subtype of T, then objects of type T may be replaced with objects of type S without altering any of the desirable properties of the program (correctness, task performed, etc.) + +The following 5 rules is required to achieve `Liskov Substitution Principle` + + - Child function arguments must match function arguments of parent + - Child function return type must match parent function return type + - Child pre-conditions cannot be greater than parent function pre-conditions + - Child function post-conditions cannot be lesser than parent function post-conditions + - Exceptions thrown by child method must be the same as or inherit form and exception thrown by the parent method + + + +```bash +php index.php +``` +```php + +``` +
+ +#### [The Interface Segregation Principle](interface-segregation) +The Interface Segregation Principle (ISP) states that no client should be forced to depend on methods that it does not use. ISP splits interfaces that are very large into smaller and more specific interfaces so that clients will only need to implement methods that are of interest to them. +- Interface = Contract +- Segregation = Divided or Split Up + +The most important things it that, if a Interface contain only one method, however it's most convenient for this principle. + +```bash +php index.php +``` +```php + +``` +
+ +#### [The Dependency Inversion Principle](dependency-inversion) +A class should have one and only one reason to change. +```bash +php index.php +``` +```php + +``` diff --git a/Solid Principle/dependency-inversion/index.php b/Solid Principle/dependency-inversion/index.php new file mode 100644 index 0000000..b3d9bbc --- /dev/null +++ b/Solid Principle/dependency-inversion/index.php @@ -0,0 +1 @@ +getMessage(); + } + + $total = $number + ($number * 0.5); + + // TODO: Post Condition + try { + if (!is_float($total)) { + throw new \Exception('Total must be calculate with vat amount'); + } + } catch (Exception $e) { + return $e->getMessage(); + } + + return $total; +} + + + +/** + * Example of Liskov Conventional Statement + * + * @param int + * @return float|string + * @throws Exception + */ +function valueAddedTax(int $number): float +{ + return $number + ($number * 0.12); +} + + + +echo autoVatAdded(20); +echo PHP_EOL; +echo valueAddedTax('12.54'); diff --git a/Solid Principle/liskov-substitution/classes/ChildClass.php b/Solid Principle/liskov-substitution/classes/ChildClass.php new file mode 100644 index 0000000..d571f08 --- /dev/null +++ b/Solid Principle/liskov-substitution/classes/ChildClass.php @@ -0,0 +1,8 @@ +radius = $radius; + } + + public function area(): float + { + return pi() * $this->radius * $this->radius; + } +} diff --git a/Solid Principle/open-closed/Calculator/ShapeCalculator.php b/Solid Principle/open-closed/Calculator/ShapeCalculator.php new file mode 100644 index 0000000..d194262 --- /dev/null +++ b/Solid Principle/open-closed/Calculator/ShapeCalculator.php @@ -0,0 +1,8 @@ +length = $length; + } + + public function area(): float + { + return pow($this->length, 2); + } +} diff --git a/Solid Principle/open-closed/Calculator/Triangle.php b/Solid Principle/open-closed/Calculator/Triangle.php new file mode 100644 index 0000000..c0e2047 --- /dev/null +++ b/Solid Principle/open-closed/Calculator/Triangle.php @@ -0,0 +1,22 @@ +base = $base; + $this->height = $height; + } + + public function area(): float + { + return pow($this->height, $this->base) / 2; + } +} diff --git a/Solid Principle/open-closed/Controllers/ShapeGenerator.php b/Solid Principle/open-closed/Controllers/ShapeGenerator.php new file mode 100644 index 0000000..9b044d6 --- /dev/null +++ b/Solid Principle/open-closed/Controllers/ShapeGenerator.php @@ -0,0 +1,26 @@ +shapes = $shapes; + } + + public function run() + { + foreach ($this->shapes as $shape) { + if ($shape instanceof \App\OpenClosed\Square) { + echo 'Area of square = ' . $shape->area() . PHP_EOL; + } elseif ($shape instanceof \App\OpenClosed\Circle) { + echo 'Area of circle = ' . sprintf('%.2f', $shape->area()) . PHP_EOL; + } elseif ($shape instanceof \App\OpenClosed\Triangle) { + echo 'Area of triangle = ' . $shape->area() . PHP_EOL; + } + } + } +} diff --git a/Solid Principle/open-closed/index.php b/Solid Principle/open-closed/index.php new file mode 100644 index 0000000..424f8aa --- /dev/null +++ b/Solid Principle/open-closed/index.php @@ -0,0 +1,15 @@ +run(); diff --git a/Solid Principle/single-responsibility/appropriate/Controllers/AreaCalculator.php b/Solid Principle/single-responsibility/appropriate/Controllers/AreaCalculator.php new file mode 100644 index 0000000..8aa194b --- /dev/null +++ b/Solid Principle/single-responsibility/appropriate/Controllers/AreaCalculator.php @@ -0,0 +1,34 @@ +shapes = $shapes; + } + + public function shapeGenerate(): void + { + foreach ($this->shapes as $shape) { + if ($shape instanceof \App\SingleResponsibility\Square) { + echo 'Area of square = ' . $shape->area() . PHP_EOL; + } elseif ($shape instanceof \App\SingleResponsibility\Circle) { + echo 'Area of circle = ' . sprintf('%.2f', $shape->area()) . PHP_EOL; + } elseif ($shape instanceof \App\SingleResponsibility\Triangle) { + echo 'Area of triangle = ' . $shape->area() . PHP_EOL; + } + } + } +} diff --git a/Solid Principle/single-responsibility/appropriate/Controllers/HumanResource.php b/Solid Principle/single-responsibility/appropriate/Controllers/HumanResource.php new file mode 100644 index 0000000..a978e69 --- /dev/null +++ b/Solid Principle/single-responsibility/appropriate/Controllers/HumanResource.php @@ -0,0 +1,26 @@ +statements = $object; + } + + public function statement(): array + { + foreach ($this->statements as $statement) { + if ($statement instanceof \App\SingleResponsibility\Employee) { + $this->result['employee'] = $statement->employeeInfo(); + } elseif ($statement instanceof \App\SingleResponsibility\Payroll) { + $this->result['payroll'] = $statement->salarySheet(); + } + } + return $this->result; + } +} diff --git a/Solid Principle/single-responsibility/appropriate/Repositories/area/Circle.php b/Solid Principle/single-responsibility/appropriate/Repositories/area/Circle.php new file mode 100644 index 0000000..c08762e --- /dev/null +++ b/Solid Principle/single-responsibility/appropriate/Repositories/area/Circle.php @@ -0,0 +1,24 @@ +radius = $radius; + } + + public function area() + { + return pi() * $this->radius * $this->radius; + } +} diff --git a/Solid Principle/single-responsibility/appropriate/Repositories/area/Square.php b/Solid Principle/single-responsibility/appropriate/Repositories/area/Square.php new file mode 100644 index 0000000..157475a --- /dev/null +++ b/Solid Principle/single-responsibility/appropriate/Repositories/area/Square.php @@ -0,0 +1,24 @@ +length = $len; + } + + public function area() + { + return pow($this->length, 2); + } +} diff --git a/Solid Principle/single-responsibility/appropriate/Repositories/area/Triangle.php b/Solid Principle/single-responsibility/appropriate/Repositories/area/Triangle.php new file mode 100644 index 0000000..30dfe91 --- /dev/null +++ b/Solid Principle/single-responsibility/appropriate/Repositories/area/Triangle.php @@ -0,0 +1,26 @@ +base = $base; + $this->height = $height; + } + + public function area() + { + return pow($this->height, $this->base) / 2; + } +} diff --git a/Solid Principle/single-responsibility/appropriate/Repositories/data/Employee.php b/Solid Principle/single-responsibility/appropriate/Repositories/data/Employee.php new file mode 100644 index 0000000..fddb442 --- /dev/null +++ b/Solid Principle/single-responsibility/appropriate/Repositories/data/Employee.php @@ -0,0 +1,31 @@ +fullName = $name; + $this->designation = $des; + $this->organization = $org; + } + + public function employeeInfo(): array + { + return array( + 'full_name' => $this->fullName, + 'designation' => $this->designation, + 'organization' => $this->organization + ); + } +} diff --git a/Solid Principle/single-responsibility/appropriate/Repositories/data/Payroll.php b/Solid Principle/single-responsibility/appropriate/Repositories/data/Payroll.php new file mode 100644 index 0000000..309b0d5 --- /dev/null +++ b/Solid Principle/single-responsibility/appropriate/Repositories/data/Payroll.php @@ -0,0 +1,29 @@ +basic = $basic; + } + + public function salarySheet(): array + { + return array( + 'basic_salary' => $this->basic, + 'travel_allow' => $this->basic * 0.15, + 'dining_allow' => $this->basic * 0.25, + 'medical_serv' => $this->basic * 0.20, + 'total_salary' => $this->basic + ($this->basic * 0.15) + ($this->basic * 0.25) + ($this->basic * 0.20) + ); + } +} diff --git a/Solid Principle/single-responsibility/index.php b/Solid Principle/single-responsibility/index.php new file mode 100644 index 0000000..0997a1c --- /dev/null +++ b/Solid Principle/single-responsibility/index.php @@ -0,0 +1,49 @@ +areaOfSquare(15); +$shape->areaOfCircle(20); +$shape->areaOfTriangle(15, 2); + + + +// TODO: Example (Bad Design Pattern) No 02: +$staff = new SRP\SalaryGenerator('John Doe', 'Software Developer', 'ABC Private Co. Ltd.', '15000'); +print_r($staff->salarySheet()); + + + +// TODO: Example (Good Design Pattern) No 03: +$square = new SRP\Square(20); +$circle = new SRP\Circle(15); +$tangle = new SRP\Triangle(8, 2); + +$area = new SRP\AreaCalculator($square, $circle, $tangle); +$area->shapeGenerate(); + + + +// TODO: Example (Good Design Pattern) No 04: +$rashid = new SRP\Employee('Md. Abdur Rashid', 'Professional Graphics Designer', 'XYZ Internation Limited'); +$salary = new SRP\Payroll(6500); + +$hrm = new SRP\HumanResource($rashid, $salary); +print_r($hrm->statement()); + diff --git a/Solid Principle/single-responsibility/irrelevant/SalaryGenerator.php b/Solid Principle/single-responsibility/irrelevant/SalaryGenerator.php new file mode 100644 index 0000000..bbd2092 --- /dev/null +++ b/Solid Principle/single-responsibility/irrelevant/SalaryGenerator.php @@ -0,0 +1,56 @@ +fullName = $name; + $this->designation = $des; + $this->organization = $org; + $this->basicSalary = $basic; + } + + protected function employeeInfo(): array + { + return array( + 'full_name' => $this->fullName, + 'designation' => $this->designation, + 'organization' => $this->organization + ); + } + + public function salarySheet(): array + { + return array( + 'employee' => $this->employeeInfo(), + 'payroll' => array( + 'basic_salary' => $this->basicSalary, + 'travel_allow' => $this->basicSalary * 0.15, + 'dining_allow' => $this->basicSalary * 0.25, + 'medical_serv' => $this->basicSalary * 0.20, + 'total_salary' => $this->basicSalary + ($this->basicSalary * 0.15) + ($this->basicSalary * 0.25) + ($this->basicSalary * 0.20) + ) + ); + } +} diff --git a/Solid Principle/single-responsibility/irrelevant/ShapeCalculator.php b/Solid Principle/single-responsibility/irrelevant/ShapeCalculator.php new file mode 100644 index 0000000..b625e74 --- /dev/null +++ b/Solid Principle/single-responsibility/irrelevant/ShapeCalculator.php @@ -0,0 +1,43 @@ +length = $length; + echo 'Area of square is = ' . pow($this->length, 2) . PHP_EOL; + } + + public function areaOfCircle($radius) + { + $this->radius = $radius; + echo 'Area of circle is = ' . sprintf('%.2f', (pi() * $this->radius * $this->radius)) . PHP_EOL; + } + + public function areaOfTriangle($height, $base) + { + $this->height = $height; + $this->base = $base; + echo 'Area of triangle is = ' . pow($this->height, $this->base) / 2 . PHP_EOL; + } +} diff --git a/Strings/.gitignore b/Strings/.gitignore new file mode 100644 index 0000000..723ef36 --- /dev/null +++ b/Strings/.gitignore @@ -0,0 +1 @@ +.idea \ No newline at end of file diff --git a/Strings/README.md b/Strings/README.md new file mode 100644 index 0000000..e69de29 diff --git a/Strings/addslashes.php b/Strings/addslashes.php new file mode 100644 index 0000000..d1d059f --- /dev/null +++ b/Strings/addslashes.php @@ -0,0 +1,52 @@ + Required. Specifies the string to be escaped + * + * + * Predefined characters are: + * single quote (') + * double quote (") + * backslash (\) + * NULL + * + */ + +// Example 1: +$string = addslashes("Hey what's up!"); +echo ($string . "
"); +# Output => Hey what\'s up! + + + + +/** + * Definition and Usage: + * The addcslashes() function returns a string with + * backslashes in front of the specified characters. + * + * + * Syntax: + * addcslashes(string, characters) + * + * + * Parameter Values: + * string => Required. Specifies the string to be escaped + * characters => Required. Specifies the characters or range of characters to be escaped + * + */ + +// Example 1: +$string = addcslashes("Hey what's up!", "w"); +echo ($string . "
"); +# Output => Hey \what's up! \ No newline at end of file diff --git a/Strings/chunk_split.php b/Strings/chunk_split.php new file mode 100644 index 0000000..dc62a45 --- /dev/null +++ b/Strings/chunk_split.php @@ -0,0 +1,24 @@ + Specifies the string to split + * length => Optional. A number that defines the length of the chunks. Default is 76 + * end => Optional. A string that defines what to place at the end of each chunk. Default is \r\n + * + */ + +// Example 1: +$string = "Hey what's up!"; + +echo chunk_split($string, 1, '.'); +# Output => H.e.y. .w.h.a.t.'.s. .u.p.!. \ No newline at end of file diff --git a/Strings/explode.php b/Strings/explode.php new file mode 100644 index 0000000..9467a80 --- /dev/null +++ b/Strings/explode.php @@ -0,0 +1,25 @@ + Required. Specifies where to break the string + * length => Required. The string to split + * limit => Optional. Specifies the number of array elements to return + * + */ + +// Example 1: +$string = "Apple, Banana, Mango, Strawberry"; +$explod = explode(', ', $string, str_word_count($string) - 1); +$explod = explode(', ', $string); + +print_r($explod); +# Output => Array([0] => Apple [1] => Banana [2] => Mango [3] => Strawberry) \ No newline at end of file diff --git a/Strings/implode.php b/Strings/implode.php new file mode 100644 index 0000000..0af6f7e --- /dev/null +++ b/Strings/implode.php @@ -0,0 +1,25 @@ + Required. Specifies the string and how to format the variables in it. + * + * Possible format values: + * %% - Returns a percent sign + * %b - Binary number + * %c - The character according to the ASCII value + * %d - Signed decimal number (negative, zero or positive) + * %e - Scientific notation using a lowercase (e.g. 1.2e+2) + * %E - Scientific notation using a uppercase (e.g. 1.2E+2) + * %u - Unsigned decimal number (equal to or greather than zero) + * %f - Floating-point number (local settings aware) + * %F - Floating-point number (not local settings aware) + * %g - shorter of %e and %f + * %G - shorter of %E and %f + * %o - Octal number + * %s - String + * %x - Hexadecimal number (lowercase letters) + * %X - Hexadecimal number (uppercase letters) + * + * arg1 => Required. The argument to be inserted at the + * first %-sign in the format string + * arg2 => Optional. The argument to be inserted at the + * second %-sign in the format string + * arg++ => Optional. The argument to be inserted at the third, + * fourth, etc. %-sign in the format string + * + */ + +// Example 1: +$total = 7.5; +$state = 'Dhaka'; +$string = sprintf("There are %.1f million bicycles in %s.", $total, $state); + +echo $string; + +# Output => There are 7 million bicycles in Dhaka. \ No newline at end of file diff --git a/Strings/str_pad.php b/Strings/str_pad.php new file mode 100644 index 0000000..e106dc0 --- /dev/null +++ b/Strings/str_pad.php @@ -0,0 +1,33 @@ + Required. Specifies the string to pad + * length => Required. Specifies the new string length. If this + * value is less than the original length of the string, + * nothing will be done + * pad_string => Optional. Specifies the string to use for padding. + * Default is whitespace + * pad_type => Optional. Specifies what side to pad the string. + * + * Possible values: + * 1. STR_PAD_BOTH - Pad to both sides of the string. + * 2. STR_PAD_LEFT - Pad to the left side of the string + * 3. STR_PAD_RIGHT - Pad to the right side of the string. This is default + * + */ + +// Example 1: +$string = 'Hello World'; +echo str_pad($string, 13, '_', STR_PAD_LEFT) . "
"; +echo str_pad($string, 13, '_', STR_PAD_RIGHT) . "
"; +echo str_pad($string, 15, '_', STR_PAD_BOTH) . "
"; +# Output => __Hello World | Hello World__ | __Hello World__ diff --git a/Strings/str_repeat.php b/Strings/str_repeat.php new file mode 100644 index 0000000..05b7623 --- /dev/null +++ b/Strings/str_repeat.php @@ -0,0 +1,22 @@ + Required. Specifies the string to repeat + * repeat => Required. Specifies the number of times the string will + * be repeated. Must be greater or equal to 0 + * + */ + +// Example 1: +$string = 'Hello World
'; +echo str_repeat($string, 5); +# Output => Hello World Hello World Hello World Hello World Hello World \ No newline at end of file diff --git a/Strings/str_replace.php b/Strings/str_replace.php new file mode 100644 index 0000000..09bd46c --- /dev/null +++ b/Strings/str_replace.php @@ -0,0 +1,51 @@ + Required. Specifies the value to find + * replace => Required. Specifies the value to replace the value in find + * string => Required. Specifies the string to be searched + * count => Optional. A variable that counts the number of replacements + * + */ + +// Example 1: +$string = 'Hello World'; +echo str_replace($string, 'hello world', 'Hi there...'); +# Output => Hi there... + + + +/** + * Definition and Usage: + * The str_ireplace() function replaces some characters + * with some other characters in a string and also this + * function is case-sensitive. + * + * + * Syntax: + * str_replace(find, replace, string, count) + * + * + * Parameter Values: + * find => Required. Specifies the value to find + * replace => Required. Specifies the value to replace the value in find + * string => Required. Specifies the string to be searched + * count => Optional. A variable that counts the number of replacements + * + */ + +// Example 1: +$string = 'Hello World'; +echo str_ireplace($string, 'hello world', 'Hi there...'); +# Output => Hi there... \ No newline at end of file diff --git a/Strings/str_shuffle.php b/Strings/str_shuffle.php new file mode 100644 index 0000000..dbb8af3 --- /dev/null +++ b/Strings/str_shuffle.php @@ -0,0 +1,21 @@ + Required. Specifies the string to shuffle + * + */ + +// Example 1: +$string = 'Hello World'; +echo str_shuffle($string); +# Output => oHlol delWr (might be differentiate) diff --git a/Strings/str_split.php b/Strings/str_split.php new file mode 100644 index 0000000..fd4a263 --- /dev/null +++ b/Strings/str_split.php @@ -0,0 +1,23 @@ + Required. Specifies the string to split + * length => Optional. Specifies the length of each array element. Default is 1 + * + */ + +// Example 1: +$string = 'Hello World'; +echo '
';
+print_r(str_split($string));
+echo '
'; +# Output => Array ([0] => H [1] => e [2] => l [3] => l [4] => o [5] => [6] => W [7] => o [8] => r [9] => l [10] => d) diff --git a/Strings/str_word_count.php b/Strings/str_word_count.php new file mode 100644 index 0000000..46f8dca --- /dev/null +++ b/Strings/str_word_count.php @@ -0,0 +1,22 @@ + Required. Specifies the string to split + * length => Optional. Specifies the length of each array element. Default is 1 + * + */ + +// Example 1: +$string = 'Hello World'; +echo str_word_count($string); +# Output => 2 diff --git a/Strings/strcases.php b/Strings/strcases.php new file mode 100644 index 0000000..6354b60 --- /dev/null +++ b/Strings/strcases.php @@ -0,0 +1,67 @@ + Required. Specifies the string to convert + * + */ + +// Example 1: +$string = "Hello WORLD
"; +echo strtolower($string); +# Output => hello world + + + +/** + * Definition and Usage: + * The strtoupper() function converts a string to uppercase. + * + * + * Syntax: + * strtoupper(string) + * + * + * Parameter Values: + * string => Required. Specifies the string to convert + * + */ + +// Example 1: +$string = "Hello world
"; +echo strtoupper($string); +# Output => HELLO WORLD + + + +/** + * Definition and Usage: + * The ucwords() function converts the first character + * of each word in a string to uppercase. + * + * + * Syntax: + * ucwords(string, delimiters) + * + * + * Parameter Values: + * string => Required. Specifies the string to convert + * delimiters => Optional. Specifies the word separator character + * + */ + +// Example 1: +$string = "hello world
"; +echo ucwords($string); +echo ucwords('hey| john', '|'); +# Output => Hello World + + diff --git a/Strings/strcmp.php b/Strings/strcmp.php new file mode 100644 index 0000000..bbcfc56 --- /dev/null +++ b/Strings/strcmp.php @@ -0,0 +1,22 @@ + Required. Specifies the first string to compare + * string2 => Required. Specifies the second string to compare + * + */ + +// Example 1: +$string1 = 'Hello World'; +$string2 = 'Hello World!'; +echo strcmp($string1, $string2); +# Output => -1 diff --git a/Strings/strip_tags.php b/Strings/strip_tags.php new file mode 100644 index 0000000..7f2d631 --- /dev/null +++ b/Strings/strip_tags.php @@ -0,0 +1,25 @@ + Required. Specifies the string to check + * allow => Optional. Specifies allowable tags. These + * tags will not be removed + * + */ + +// Example 1: +$string = '
Hello world!
'; +echo strip_tags($string); +echo "
"; +echo strip_tags($string, ''); +# Output => Hello world! | Hello world! diff --git a/Strings/stripslashes.php b/Strings/stripslashes.php new file mode 100644 index 0000000..0c02f8e --- /dev/null +++ b/Strings/stripslashes.php @@ -0,0 +1,39 @@ + Required. Specifies the string to check + * + */ + +// Example 1: +$string = stripslashes("Hey what\'s up!"); +echo ($string); +# Output => Hey what's up! + + + +/** + * Definition and Usage: + * The stripcslashes() function removes backslashes + * added by the addcslashes() function. + * + * + * Syntax: + * stripcslashes(string) + * + */ + +// Example 1: +$string = stripcslashes("Hey \what's up!"); +echo ($string); +# Output => Hey what's up! \ No newline at end of file diff --git a/Strings/strpos.php b/Strings/strpos.php new file mode 100644 index 0000000..dd09aa1 --- /dev/null +++ b/Strings/strpos.php @@ -0,0 +1,75 @@ + Required. Specifies the string to search + * find => Required. Specifies the string to find + * start => Optional. Specifies where to begin the search + * + */ + +// Example 1: +$string = "As a appliction developer, php is the best technology where I used to"; +echo stripos($string, 'php'); +# Output => 27 + + + +/** + * Definition and Usage: + * The stripos() function finds the position of the first + * occurrence of a string inside another string and also this + * function is case-insensitive. + * + * + * Syntax: + * stripos(string, find, start) + * + * + * Parameter Values: + * string => Required. Specifies the string to search + * find => Required. Specifies the string to find + * start => Optional. Specifies where to begin the search + * + */ + +// Example 1: +$string = "As a appliction developer, php is the best technology where I used to"; +echo stripos($string, 'PHP'); +# Output => 27 + + + +/** + * Definition and Usage: + * The strrpos() function finds the position of the last + * occurrence of a string inside another string. and also this + * function is case-sensitive. + * + * + * Syntax: + * stripos(string, find, start) + * + * + * Parameter Values: + * string => Required. Specifies the string to search + * find => Required. Specifies the string to find + * start => Optional. Specifies where to begin the search + * + */ + +// Example 1: +$string = "As a appliction developer, php is the best technology where I used to in php"; +echo strrpos($string, 'php'); +# Output => 73 + diff --git a/Strings/substr.php b/Strings/substr.php new file mode 100644 index 0000000..1aad5b2 --- /dev/null +++ b/Strings/substr.php @@ -0,0 +1,23 @@ + Required. Specifies the string to return a part of + * start => Required. Specifies where to start in the string + * length => Optional. Specifies the length of the returned + * string. Default is to the end of the string. + * + */ + +// Example 1: +$string = 'Hello World!'; +echo substr($string, 6, 2); +# Output => World! diff --git a/Strings/trim.php b/Strings/trim.php new file mode 100644 index 0000000..28a5a5f --- /dev/null +++ b/Strings/trim.php @@ -0,0 +1,31 @@ + Required. Specifies the string to check + * charlist => Optional. Specifies which characters to remove + * from the string. If omitted, all of the following + * characters are removed: + * + * "\0" - NULL + * "\t" - tab + * "\n" - new line + * "\x0B" - vertical tab + * "\r" - carriage return + * " " - ordinary white space + * + */ + +// Example 1: +$string = ' Hello World! '; +echo trim($string); +# Output => Hello World! diff --git a/Utilities/AndroidNotification.php b/Utilities/AndroidNotification.php new file mode 100644 index 0000000..91771dc --- /dev/null +++ b/Utilities/AndroidNotification.php @@ -0,0 +1,88 @@ +server = $server; + $this->device = $device; + $this->title = $title; + $this->image = $image; + $this->detail = $detail; + $this->type = $type; + } + + private function notification() + { + $this->headers = [ + 'Authorization:key = ' . $this->server . '', + 'Content-Type: application/json' + ]; + + $ch = curl_init(); + curl_setopt($ch, CURLOPT_URL, $this->url); + curl_setopt($ch, CURLOPT_POST, true); + curl_setopt($ch, CURLOPT_HTTPHEADER, $this->headers); + curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); + curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0); + curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); + curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($this->content())); + $result = curl_exec($ch); + + if ($result === FALSE) { + die('Curl failed: ' . curl_error($ch)); + } + + curl_close($ch); + return $result; + } + + private function content() + { + return array( + 'to' => $this->device, + 'data' => array( + 'notification' => array( + 'body' => $this->detail, + 'title' => $this->title, + 'image' => $this->image + ), + 'notification_type' => $this->type + ) + ); + } + + public function execute($confirmation = false) + { + if (is_bool($confirmation) and $confirmation === true) { + if ($this->notification()) { + echo "Notification send successfully"; + } else { + echo "Oops! something went wrong"; + } + } else { + $this->notification(); + } + } +} + +$notification = new AndroidNotification( + 'AAAAn6yDqlg:APA91bHG9LpmiNLVasEE0mC8v_2gsdGo5N-b5xI9Xv4jN717f4SLIfoev1B7QcWBxCLxGqaAaDd5ArgFGuzS6R3SEZ2Gi6yEhMXRZxMPRfhARanKsqlp4jzI4pLd25ZBKPUOFvR6vcQK', + 'd3u97ERZTByX-sOP1kP3Kt:APA91bF9PMfitiA3UnAYpSSAUA2YYakWwFf2Y28GIol-vAbiQVf_xv8B5-Y_CRb72lCrIMbpADat5ci-XSVsOAtyWRaFdPYxKDvU4HYkK29ieE6og3k43SUWa7bLSkgg6ddvOxfF51xm', + 'Android Push Notification', + 'This is a test title for android push notification using PHP', + 'Confirm Request' +); + +$notification->execute(true); diff --git a/Utilities/DateManipulation.php b/Utilities/DateManipulation.php new file mode 100644 index 0000000..0d718b4 --- /dev/null +++ b/Utilities/DateManipulation.php @@ -0,0 +1,111 @@ +month = !empty($month) ? $month : date('M'); + $this->years = !empty($year) ? $year : date('Y'); + + $array = []; + $weeks = 1; + $dates = new DateTime("$this->years-$this->month-01"); + $count = (int)$dates->format('t'); + $parse = new DateInterval('P1D'); + + for ($day = 1; $day <= $count; $day++) { + $array["Week No $weeks"] = $dates->format('Y-m-d'); + $dayOfWeek = $dates->format('l'); + if ($dayOfWeek === 'Sunday') { + $weeks++; + } + $dates->add($parse); + } + + return $array; + } + + + public function dateDifference($date) + { + $interval = date_diff(date_create($date), date_create(date("Y-m-d H:i:s"))); + + $min = $interval->format('%i'); + $sec = $interval->format('%s'); + $hour = $interval->format('%h'); + $mon = $interval->format('%m'); + $day = $interval->format('%d'); + $year = $interval->format('%y'); + + if ($interval->format('%i%h%d%m%y') == "00000") { + return $sec . " Sec ago"; + } else if ($interval->format('%h%d%m%y') == "0000") { + return $min . " Min ago"; + } else if ($interval->format('%d%m%y') == "000") { + return $hour . " Hours ago"; + } else if ($interval->format('%m%y') == "00") { + return $day . " Days ago"; + } else if ($interval->format('%y') == "0") { + return $mon . " Months ago"; + } else { + return $year . " Years ago"; + } + } + + + public function timeCount($datetime, $full = false) + { + $now = new DateTime; + $ago = new DateTime($datetime); + $diff = $now->diff($ago); + + $diff->w = floor($diff->d / 7); + $diff->d -= $diff->w * 7; + + $string = array( + 'y' => 'year', + 'm' => 'month', + 'w' => 'week', + 'd' => 'day', + 'h' => 'hour', + 'i' => 'minute', + 's' => 'second', + ); + + foreach ($string as $k => &$v) { + if ($diff->$k) { + $v = $diff->$k . ' ' . $v . ($diff->$k > 1 ? 's' : ''); + } else { + unset($string[$k]); + } + } + + if (!$full) $string = array_slice($string, 0, 1); + return $string ? implode(', ', $string) : 'just now'; + } +} + +$object = new DateManipulation(); +print_r($object->weekInMonths()); +print_r($object->dateDifference('2021-06-23 04:50')); +print_r($object->uptoCurrentMonth()); +//print_r($object->timeCount('2021-06-23 04:50', true)); diff --git a/Utilities/DistanceCalculator.php b/Utilities/DistanceCalculator.php new file mode 100644 index 0000000..5e0befc --- /dev/null +++ b/Utilities/DistanceCalculator.php @@ -0,0 +1,43 @@ +latitudeFrom = $lat1; + $this->longitudeFrom = $lon1; + $this->latitudeTo = $lat2; + $this->longitudeTo = $lon2; + $this->convertUnit = $unit; + } + + private function calculate() + { + $theta = $this->longitudeFrom - $this->longitudeTo; + $dist = sin(deg2rad($this->latitudeFrom)) * sin(deg2rad($this->latitudeTo)) + cos(deg2rad($this->latitudeFrom)) * cos(deg2rad($this->latitudeTo)) * cos(deg2rad($theta)); + $miles = rad2deg(acos($dist)) * 60 * 1.1515; + $unit = strtoupper($this->convertUnit); + + if ($unit == "K") { + return sprintf('%.2f Kilometres', $miles * 1.609344); + } else { + return sprintf('%.2f Nautical Miles', $miles * 0.8684); + } + } + + public function run() + { + return $this->calculate(); + } +} + +$distance = new DistanceCalculator('23.6343304', '90.4893884', '24.3634014', '88.6048212', 'K'); +echo $distance->run(); diff --git a/Utilities/InvoiceAmount.php b/Utilities/InvoiceAmount.php new file mode 100644 index 0000000..c03ffb9 --- /dev/null +++ b/Utilities/InvoiceAmount.php @@ -0,0 +1,57 @@ + "FOURTEEN"]; + $tens = ["ZERO", "TEN", "TWENTY", "THIRTY", "FORTY", "FIFTY", "SIXTY", "SEVENTY", "EIGHTY", "NINETY"]; + $hundreds = ["HUNDRED", "THOUSAND", "MILLION", "BILLION", "TRILLION", "QUARDRILLION"]; // Limit to Quadrillion + $num = number_format($num, 2, ".", ","); + $num_arr = explode(".", $num); + $wholesome = $num_arr[0]; + $decorum = $num_arr[1]; + $whole_arr = array_reverse(explode(",", $wholesome)); + krsort($whole_arr, 1); + $returnString = ""; + + foreach ($whole_arr as $key => $i) { + while (substr($i, 0, 1) == "0") + $i = substr($i, 1, 5); + if ($i < 20) { + @$returnString .= $ones[$i]; + } elseif ($i < 100) { + if (substr($i, 0, 1) != "0") $returnString .= $tens[substr($i, 0, 1)]; + if (substr($i, 1, 1) != "0") $returnString .= " " . $ones[substr($i, 1, 1)]; + } else { + if (substr($i, 0, 1) != "0") $returnString .= $ones[substr($i, 0, 1)] . " " . $hundreds[0]; + if (substr($i, 1, 1) != "0") $returnString .= " " . $tens[substr($i, 1, 1)]; + if (substr($i, 2, 1) != "0") $returnString .= " " . $ones[substr($i, 2, 1)]; + } + + if ($key > 0) { + $returnString .= " " . $hundreds[$key] . " "; + } + } + + if ($decorum > 0) { + $returnString .= " and "; + if ($decorum < 20) { + $returnString .= $ones[$decorum]; + } elseif ($decorum < 100) { + $returnString .= $tens[substr($decorum, 0, 1)]; + $returnString .= " " . $ones[substr($decorum, 1, 1)]; + } + } + + if (!is_null($sentenceCase) && $sentenceCase === true) { + return ucwords(strtolower($returnString)); + } else { + return $returnString; + } + } +} + +echo InvoiceAmount::init(1250, true); diff --git a/Utilities/OnnoRokomSMS.php b/Utilities/OnnoRokomSMS.php new file mode 100644 index 0000000..fa5d24d --- /dev/null +++ b/Utilities/OnnoRokomSMS.php @@ -0,0 +1,61 @@ +notify = $user; + $this->message = $message; + + $this->execute = 'op=' . $this->opt . '&type=TEXT&'; + $this->execute .= 'mobile=' . $this->notify . '&smsText=' . $this->message . '&'; + $this->execute .= 'username=' . $this->userName . '&password=' . $this->password . '&'; + $this->execute .= 'maskName=' . $this->maskName . '&campaignName=' . $this->campaign . ''; + } + + private function execute() + { + $ch = curl_init($this->url); + curl_setopt($ch, CURLOPT_POST, true); + curl_setopt($ch, CURLOPT_POSTFIELDS, $this->execute); + curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); + $response = curl_exec($ch); + + if ($response === FALSE) { + die('Curl failed: ' . curl_error($ch)); + } + + curl_close($ch); + return $response; + } + + public function send($confirmation = false) + { + if (is_bool($confirmation) and $confirmation === true) { + if ($this->execute()) { + echo "SMS send successfully"; + } else { + echo "Oops! something went wrong"; + } + } else { + $this->execute(); + } + } +} + +$sms = new OnnoRokomSMS('01316440504','Object Oriented SMS Sender'); +$sms->send(true); diff --git a/cURL/.gitignore b/cURL/.gitignore new file mode 100644 index 0000000..723ef36 --- /dev/null +++ b/cURL/.gitignore @@ -0,0 +1 @@ +.idea \ No newline at end of file diff --git a/cURL/README.md b/cURL/README.md new file mode 100644 index 0000000..e69de29 diff --git a/cURL/web-scrapping.php b/cURL/web-scrapping.php new file mode 100644 index 0000000..b3d9bbc --- /dev/null +++ b/cURL/web-scrapping.php @@ -0,0 +1 @@ +~f-M7j}BQn-BYKXLDz zIdkUBZ}XhzQ|~)!vQko0AOr+$Nih{I6+VT5*FDF}a3KP7?|eJk<6HjV!C#!*|2r_f z6bHALIKAS^@`)Vce6zKM*2$?vzl@sI>AA%f)42z4-3ncJ_Frf_e=Mxt+*PfiPo+1= z-nNceJuP-vBW!D}^{83JVveR{w{6C;p2V8KVr$_AbK{g+9YWTsvD>h!Lr+O?Brx-< zyM(gm7FBrKdTKm0o5ivh7qe?t9li`kE@M?I?O|(L>7R}7TH0{is7p@v)Ev8&8<&4) z)XZh`uGB+YJ1uy!ZWrOMY++iwswSLtNH_E3TTCpMd&u5Ml{0TA?38;S-D|GZw$j&4 zxH3ue53;bJP^t=9L@Hi6FIdJBNf(c7KZdY+l!rpPd7J1BJol>;vDlQC?Y$=7pvN0x zFk&D;In#x|w%bob4zAhsagV&zHz0|28cy&40o7UWBw4F6?9fPFbAOIW+VBhK; z*V>7e+F#fI<``+i3&CYZFyWoZW$@3JftS!1q!-j@+$ZY)n*$NrIyMR0?ty=Osk#mk z`pyTzrjG`0FVwpfP5G(Yf4~Z9sDf_B4U`PyF^9X8Ju)|cZz{~`W@iZ@?h>|2S@rEU z4M8H#Rh0C*E8E-7QW51Hd;+ueHz4L7^PdBsi-O{p6>5S>b(He@X0$bMaD%(adfgOF z)Xc0B$r$2D_xY{wKHfeSAQU)?xo^|%P$Hr@eQmUw-`X3VXib;q+V|uZ4a0J!HT)#wb5T!Gx6ysFuangg z(j2_zkQD{^7&G|YTw*YHj?MB6u_tM4p!ESkCio;E5A{xFz+Tz|;eudkH5_$4Ch%zg z9cJ2gr65bCiq(9b_cD0I{)28zb;v#HyNu_|~i z&2Sf12Q~;P(%C)iF~Y>Fj9{Gr(fJ4ScfD?=jX9D}u6VN@&h8Jwgryu+GKn#F7IkeR zM?zd|9B5Y|g3ApFnBVFnX@BO2O6%I6LD&R_TRn_WLGv_Q&sw5))>6v3wb?XB+lznko|#Y{_crSRTDb|umL`*hM1YeMoY z#nKFT*NelbBAWeObVzek5Y*-ys!mj#-F5tbzuny| zKp&%6nj)H@LVOk`-YW^?A4dOce^Cq*@4Wf_uQyY?46WUH{{2)&{K;6!x;i=xv{k-i zH=SorE~u+40Wz<0@%P>!9Hp8)(7>Ab7mTd7{v~@eTOFT&P?mP?i$=%RTPN-ZA~O{& z)bW!w54xW+?MSB%*LWzabhI3#Q9~<%zNeo)$^vbf5}di~-kb9ekM*Bef3hIQcXCHb zA956{u$ht-{W?`Y+~-K*`8Iot$thn+f;@61QPY9XzgH*K-vTh+1MffT_(V{3`qWCB z^wx?5=8ET__C=?596+-H`R%-V;8p@bDD2C`3Vb(ZWVj?{a(mzj8r?lrhYBzrY^{sq zG5Fa<52(W#u-k$!%#$4!TW#aV4`~=CcDGtnCSw6_5{_T)RZxF-6UGMiWu@>STE4W0 z65Q%wg}KYxYrMlD^WZ2s8BS|WM=dQ$8dBOF`za}ng3=CJRI7^ z`7SBu?#&93xy&!XM9_I)&rfJj?X{FuA%~X*73_KGUVwm4h47^4S)1_heixTlselZV zv9%JaKy65y@eC5i)(5XrVwp_r07|bSgr$PK3?`w#Q#gV?6s&S57#LXA&`qx+h=QZl z*z_Jie(P++p^CbjS)o3;wFa=yE?rfUd#+@dzXNg9@ym=M|9Lf49^mt;W9fS zsC-4L-lBFA5x?hu_<`7Pq-tgx9!KB3vH zU)ZuF^^L=VQs#EZwdIN3XM~AC>EC!N7c4#tUG)lm7mZAI`|>7oT{bve4Xg3i_kDjj z^Pi=h+diWsJ)5e4qj7e>c)kTWLid>|v)eodV6D95wsn8Q&AGGBj^$Mtp$QDmuI zl)fdK3Y3z|cJDenPU!?Zv@=EGn6geONF4t`WQR$Ir& zT!9i?CwyaNvVAGS*Kh4N-+`Ty9QSWNJw0Tg@_SsG*Zh{nu0i=#XLg?@2)XQc~ddw25#%o1L%HmDr6;1EVHF4rI|dk)1_ zxw1sDT1+T+(N}z^y5k^*P|%e=M&klcce<13_vZJ^t1!(fuJ@CG6ni2_xOej?di{j=}VhMfu#h zR|(cbx%c5Ot&8*1gDfp3Bl=fd4o)_+EG}qoOj?w8)VPY&w0_&2`W%d)7>ya|s8bgE z<;zT&vnfX^H_ohgR8RrEE-2@#Ya3v-G>SkmIJ3>R7p!%W+hUr(wNqN(uJ4mm%JBW~ zL9b%DdmB&SNd9u7X6<4R!&q6lrfEY>e?)yPc++dib#?e8)0>;Urmhc35CyBTD=F&P zUQhAB6P#1t;S+$Z$Z_ba_T$^qcl!I*v$sO4$D8H8f{;4rpT5l{1-?D!e{;%j`v^bm zyqmERJV7?(uxg`Tz9_LJBDrXoS0iUL#Pl`%RPMLQkaTL5RI6xryz+U+tmfa><<@B^ z9#F=Li><9kNhwQdhFLWv4-^+yCSS~-)5^Hh&*q6 zjl{KQYc6%ac%JoJmtlS^?ln@R5&BxNFL@GT=)Hy9G5`Br> zh4@-ohX*YMa$Sbo)7JH#>bN=6$S0hFYMD{BI7RTxA@ieP{E_*t_iGv{MqKOS}e>G2+uWwJ}t=+M?|yMctdvsQnJra8( zw$j^i;I)eK@y+S1=v-qKe<#|e21W~pl{m`G z+6zi8HjhH$oBCDYr1+{tk#q_>`#e z0fRfN2Z?9jKM-JNh5ZH5cfe7hah=d4<;TdCT`C4YPpIs(*V1-=s8nNUZ+S>TSO|i9 zIxD_TvxFFx_sCeG2R#G-DnTPXhwQ7fqTbLZ8V$)GA zHSwonb#AY8EZRg<&@UH5&nrzGV3`$PTObiRL*MY*WX=0hJp&5{1h;q{!VcQ$BfrW7rlR{;m$>gnZ)BM}ma!fL?BVN)nqi&+xx{BH@E}px{2$sO z1_o$K%xjBsN?WJMZ{I8^)iF*CshS31m$FlIkY>&;Uc>)5hQ;ZRi41+`e3`06hSeh< zUY^Qy(q_MX^$a$(dZ<>+ZMsktRg*5w2?SoZ7T!Ntt_4B2*+^_ZMW5K4lQ*Ey8oXbh zp!t^)U=BEdrvoyTupouPf6XW+#6OFWyB=Th-PQQ4qTL~X25^qd7xC@1htXB8Gn8EV zikv2n;HVvaib1mm*X?3P_1BL9JZ*hRN7ztsbZo+xn3-Tf@spq}#QO(@2VNIuDKJDv zl-6(|oT-{8JcK?~57ox(!wyBI$6dgql|l*YFNYu2;*WXU&`+}u*L;88%Vdgis%P7b zf;m0YS0|$9%y`rc@GCyzXygLO>0ZokL zj*g&G)~k`OUADV+LeikRAGOPkUPU7TPLMWx44V^=VYzJu5+_SoTNP`JT2wkqcrDaH zD^GRZaoeRg(6^0Z>zLSsVW8N-p&>j)%E2!Wi*Q>C#kMd`&M579sS2AFwHeG+kK~T& z?cX6#tfV6}U$U9@?MwpZ@R;Rem^U)Ch?<=`v8XydtIVVbjZ>?^=I-xyEq*)A>FFJ< zWXXE0r9jd0^`9oR4}*7fT!(q82_MbMi>_RNZQ_&My()$p1+bihDN|4hKiRatCHH+o zYh$pPTq+9?lx(0ymZfALk&RXg$!=4?@k8+5k~l+xT8M*;Rb^*?iz5FWY&|lMJLwgj9x({sqSbg2o*K zfR|bz-=xU7B03hv8Tf&-nl?^t+f8&f0M23+@Fa^Ce+3xG?~jQUZaRID!k>sEl~FZ0 zlPEm=AP)Mc@}JL$I7Kjs9TC{64G80lcy>wD0Eyq zYP@}>uE4o_NtXD5_SJt{4+*jtoi%@F0dmV$W}+T-B4tZURn>aru+!**4%v{e|7;v_ zd1H~9G<~Sjf5Kb2nTCeWg=~_c4zLm(C(=x&W}{dbXq|gw%Xoh~%nw5-FVuAMC^m$S zve`F%_-y=abJ*_?K!PA^`7l4wn$EBQ6jhRypeF*wMdXBd>4X}A6;dAatZ{L!ty_L> zImto#8<6M503@VHc)3Kv%UIds^fn8&G}Hvk%V8_R!8I*n+;fB>>Add<|Nh zK=F8_D+!Aw(WA-~H3lI@g_k|ka<}Z6KLf-;sF2=eG?Ll)G6Sdy|1OB84K5@!AtqNQ z`jFxlN~QNz;e>h1I<EDQ!{HJ$E)F+f#rn=NV_G zG(pzFM?Q9gQT+AXNdd@^U>zcOkgdEBw_K;POmzQUDgYd*=Ls7zpsB%{@^SjDM7>+T z7{)sC&!5s#yoXDMmxK|^z00T=xwX?pLoc4bh(vpWt;oGQWT5@c2xZV6j)T8`4%sL6 z7A9c=8QeO9pK_eB@7zLnEvqq0YKt{+B9CS;xOd6ChWfwo&Rb>dCkg)B%~!ULN4FW% zG%&%)x_T$Djo1my#*Mlnm*Wlxbwl~Hrp#`fzK|SfYPU+@-pH?sDyvBxlbaE#jJk&& zbGk<{VmEVUbE)e1euS}f4oq>DRsDk}HNQ)+k#FPObi+$-!fGm0$$GX&V~wswQwy7d zc0(VwN;5Fj27t_i3d$!mL7BlJblr+B$=tD2a*5%Lq-K#&E!R*Lfvjz3&MVvvm{e(5AH}im?oe~ zK?*t}Ao|M9*U527E|}%4vlox-84o+c*w+Dm7MeROA7nU&4(l+vAO zHmS&~(D8g@6YVft{Mq(wp&SwrpH;SeHSA_LYL*9&5;DpXSI= zLs%v14I!atfmG(3PSPRI8BdU@H6e=V`XYvF+W8u6fixbwYcvNsoL2?WqD|Gs0;Q)r zBY-hG5x;Ejj_?7VHp>4@=p8#hLEoA-X9$%4sH6#}GCBUd4T@qy1v6!XX?i~~jsQIX zc5#@e@DRidU$42xv_gaCBT_A?%8 z-cG%c*Jv$(Kdlgv%-+Yav36ia-J8&S^rpFnGmiDkR}sSP-{dx8O|MimUK{U=vi+%W z!p|L@pjMdVv(n~GV{Wz681t3F5u}%~4zNgpHnTLjf#LsxB^-cX^Orl3e5j4L@L#eY zf3J^`+uJaidwJ3!q)fCv8ouwSV8*W(f-|APOT*$n(-+0f>B+kMFdr*iQ+vUYmVB|Q zQ!W)JCo`-#0fMpXfXKIG{0;`tY&%6nwo(tUP+D9HbCw~xjoDaV0bQSILZy4lep9Ok zcUJ-4?%z^5w99~PyKo`AY)_R8wd06am16o3o~rKRUpS`ZJjT3<|ALb=-o;U|mr8C3 z$jO}ZL5I%3w=qNV`be@R(g>{8n6c*$@YOO2f5uV@%q%J7>i*iwpj4RUY8dy#0Hl#e zunXJ(5!vy+rbCI}U2Cf7bkf50(nbk?+AeSB>a1!Dd0Y~BUDX`I9o^VaQU*MfWqG0z zj6>fmpj1iG11;#=kYQv;wGTMRon<^Yj+4!)Wr5Kr&7XlDyF8tKPN-L59;-X}y8>g1 z#IYfxRjs6oPzsiO#_$j&xqT!C%q!N@)4#Rdx~u-~x??yq)jRXq27$7n@nV*XVt_yn zWtRvB2840uAq^4<{(dzo!tyS;Kv5-A>ltfVXM>7MW2>=An>VTQ(Cat0{9^-d0Kr5{PjLYtBE6qzb>VJ0IztElA+HP9DPxdU$)@LcIl{M@74eZgAND!5x z8FvIp|oK&Hg4QP6nwB;VrWAhlZ^Mdm^tDz6>zT^!k|G{Xxz656DF2k&m@$| z#j=kd{9FQof%KY zv>{LL2r-haD&qk>kh@UxaY_EPZ~0s}hTk`2&b2Rp!f5JbnT)`M?Ulm%K@RW9b-wJA z0}z&?!26nQv;lHw&BZ+7;frEvl9L!;CA@B|GA?l~my0=UY@)~4$^T-&8Gv@egLC#} zXyaZwd{<@AX@O9MOl%c979!Nwn1IwUtN3~I0Dat@&0LzJhczGfvXJykR+P}FmL=jh zpxT!mW_jVyDrZgDEW`la#HnP%g3LSHNT7^sTqDa1qQNCte=#wvaoCfL4Y_E7al=ata*3tN?>2b+4>ldF< z0kIAxL$8|+z2;y$UMV9b@gHKNOJ}MEFR{PmR??x>FuYj>@iaTRv}G?uubY?{WoL!` zYw%w=atu=a&XVwVN<3zZ6JgmC8Yd+IoMi#3gXE{Ds9!Wl%rBQJc|0bp9m=GD=&8+D zGYI37kv+@5G0|+zY zB#v~xXXrAWw{^_a?%#bSjfnlJCi1Q|tO_krOL3rx z#gi1d6u2!T4iMF!T|P`G2^Q|rwS6SF86tEx(~g&h!?jWt-w8YS57tFc(yv7LD$ zIaCeiG$5!IPGN?XHeW%zd+Or^PM=8Vek*6&1hq|>l`mCNWfEF%(1~i%q++C$YG?`t z0lfOq6`IRBNT0Bn-C&!es(N5 zdd6GxSB=mAnMc}rb_zM8GC+aXzN)L#QwcKFo#)X_w;WqxF%bzawT_dMmx~50E|n>9 z4qBC#sW=Ez*L$+$nDmhRXvi#HlWstzRY~^Nt2xt@CN5bPAZxj2aX~I&>NFa_4ESN* zCAoOqSlk<9onHHG+A19}J6C}YMxsG5bKWkiiL$|E@@BK0RRFxLXP2&6_q(^+C@((& zlTp2nsYsn^@lQ3w#7HA9$}M7I*n?zM{OSy6TLC<`pvjZmtBV}YoiZMsB7KzVr=A~4 zcDus*v}yQ(bK7f0qEkszUB0KobX4s$;D;EEHf?H*ny4*Uxywu5mh=u`b8NfaL?e#r zRzSWk)6~Ic=0Y@`-gNl4Xcs<>I&ozBOeV9*N7*B>5%tS-9IBY*Tc69Q@TKmW<43wr&>p@Ep7 zZp)PulA%@olgqeY$vo<%%qBQOZ4qooK&r3qGd@d#LHWWSl}}wNq)v&xm&&~NJFP{L z`77aT`{19VXS*S)PBRaUw)^bQO!eZw=fG8qm_ik=s?mT8J{WS#iM1#(SudVxVUSY`=6$*h_j@9?+D%#9+-41#j=D{1i;;A2l3dCb*(Q|HD3zIPS3 z^pN#iwj<&)498hAAS};TR_gtTFwB- zd?QCJp?EsRjFw`{K5TuE+9n^TEcwfCunMlENo*|`-}j%LLr@Y9xLc%=7XEW=d50Rs z4mT0=@)tkdRcWT#wV)zY{thWSDkRT5=f_9!3-I36xtQMvgOFq4#jdl8}SY z<_lCh)xnwMMrP>%KI3yuwH z^8bO zxBUKQ-CJPMkQ*=A)0&@*s-|!4L(>wwyU!g3q=!MO>J;~e4mc-Xa~RUkl@TbC zI5m5KpZtkM%WAK;+v!esN$=4_z2&G^NCxm24)FWKxXoBeJ!!U5;YRaur9!_qP9Q<& zADEhHO+NtphjZ#sIhAP^XFgjZN02{FK{ zp9jH` zjpBKz2|Z}eff4f_X#{#KiTiZ>^VB-)Yt`cB3~pocvm|8DTEaA#6LHsC3a>~1QP*Y3 z=wv!rcPsc|t-9SHVt#+&$nP3%oqOQuzv~kfiiQ@p-^C1?_OJ1ShEPa=x80*wNg?&D{qAThk4m2Xq-idcrFs ze7*m+82>lF-M_|@>NGV>`QSeKPAoc9QLd)-%U8TUGz|M<1h#+dxb7WHfj^fKw&Ba&K=gEIB T(GOoPZan$_U%Y3bjv@IU^m;eY literal 0 HcmV?d00001