{"id":20961195,"url":"https://github.com/svendolin/kungfu-app","last_synced_at":"2026-04-01T17:02:40.566Z","repository":{"id":134333658,"uuid":"458567230","full_name":"Svendolin/Kungfu-App","owner":"Svendolin","description":"Kungfu App about PHP, OOP, PDO, MVC and more kindly provided by Rene Esposito, adjusted by me :D","archived":false,"fork":false,"pushed_at":"2022-04-10T19:02:25.000Z","size":15602,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2026-03-27T14:27:47.604Z","etag":null,"topics":["mvc","mvc-pattern","oop","oop-principles","pdo","pdo-mysql","pdo-php"],"latest_commit_sha":null,"homepage":"","language":"HTML","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Svendolin.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-02-12T15:53:29.000Z","updated_at":"2024-01-22T16:08:32.000Z","dependencies_parsed_at":"2023-05-03T02:46:49.040Z","dependency_job_id":null,"html_url":"https://github.com/Svendolin/Kungfu-App","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/Svendolin/Kungfu-App","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Svendolin%2FKungfu-App","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Svendolin%2FKungfu-App/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Svendolin%2FKungfu-App/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Svendolin%2FKungfu-App/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Svendolin","download_url":"https://codeload.github.com/Svendolin/Kungfu-App/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Svendolin%2FKungfu-App/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31290538,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-01T13:12:26.723Z","status":"ssl_error","status_checked_at":"2026-04-01T13:12:25.102Z","response_time":53,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["mvc","mvc-pattern","oop","oop-principles","pdo","pdo-mysql","pdo-php"],"created_at":"2024-11-19T02:01:40.320Z","updated_at":"2026-04-01T17:02:40.489Z","avatar_url":"https://github.com/Svendolin.png","language":"HTML","funding_links":[],"categories":[],"sub_categories":[],"readme":"![GitHub commit activity](https://img.shields.io/github/commit-activity/m/Svendolin/Kungfu-App?style=for-the-badge) ![GitHub contributors](https://img.shields.io/github/contributors/svendolin/Kungfu-App?style=for-the-badge) ![GitHub forks](https://img.shields.io/github/forks/Svendolin/Kungfu-App?color=pink\u0026style=for-the-badge) ![GitHub last commit](https://img.shields.io/github/last-commit/Svendolin/Kungfu-App?style=for-the-badge) ![GitHub code size in bytes](https://img.shields.io/github/languages/code-size/Svendolin/Kungfu-App?color=yellow\u0026style=for-the-badge)\n\n\n## \u0026nbsp;Content: 💬😀👍\n***\n| Folder: |  Content:  | \n|:--------------| :--------------|\n|affenschwanz| \"Affenschwanz-Prinzip\" mit ISSET / FILTER_VAR and SANITIZING |\n|API| (i) Searchbar mit TMDB (The Movie DB Datenbank) with API for direct database request |\n|bootstrap_formulare| Formular with Bootstrap |\n|datum_Zeit | Date Time |\n|einfaches_cms | Easy CMS without Database |\n|einfaches_cms_db | Not-so-easy CMS with Database |\n|einstieg OOP| (i) Classes / Superclasses / Method (class with function) / Extends / Constructors / functions / modificators|\n|fit_fuer_MySQL| MySQL exercise|\n|formular_validierung| Email / Regex Password / String length (filled fields)|\n|formular-elemente| How to write a form properly (labels, buttons, POST)|\n|joins| Innerjoin / Leftjoin / Joins for Tables / Primary- Foreign Key + Index / namespaces |\n|login| Procedural Login with password HASH and password VERIFY |\n|OOP_uebungen| (i) Dateiupload (Image) / Formular Validation without DB but with ERRORMESSAGES / Image Gallery |\n|pagination_Seiteninhalt| (i) Showing content splitted on various pages (1 of 7 etc) |\n|PDO| (i) Connect to database / Query a database / Using CRUD-Operations / Apply the MVC Model / Login with PDO / Login and registration with PDO |\n|sessions| Mistakes / redirect / write / destroy |\n|weiterfuehrend_OOP | (i) Continuing with Frameworks |\n|zusMaterial| Additional Material |\n\n\n\u003cbr\u003e\n\u003cbr\u003e\n\n\n## \u0026nbsp;Licensing: ✅ \n***\n* Basic structure, basic comments and design belongs to Rene Esposito, Instructor of \nhttps://www.sae.edu/\n\n* Adjustments are made by me, Sven Kamm, for a better personal understanding and comfortable usage in the future\n\n\u003cbr\u003e\n\u003cbr\u003e\n\n## \u0026nbsp;Before to start: ✅ \n***\n**Useful steps:**\n\n1) Make sure you installed XAMPP or MAMP to work with a localhost on an apache-server\n2) Copy this in your htdocs folder to work with your PHP-files\n3) Have you heared about MVC (Model View Controller)? here you go: https://www.youtube.com/watch?v=3OKOe7CraGY\n\n**Why OOP?**\n- OOP uses seperate files with concerning tasks - Its better for group work and organized processes\n- Do more in less time: Develop together, changes of code can be made collectively\n- You can re-use the code (less code to compile)\n- Easier to build larger websites\n- Basic PHP (Procedural PHP) still has to be learned for the basic understanding\n\n**Why MVC?**\n * it's a design pattern who takes care of database processes and CRUD-Operations\n * When you chose the way to write PHP-Code with OOP, you automatically start working to use MVC\n * Although connecting to MySQL-Database the procedural way is improved with i = MYSQLI, but for every other file\n you have to duplicate the code. MVC makes it much easer (1 to 3 are three different \"people\" or classes):\n        \n\t\n\t   0) We want to share our secrets and content: DB\n\t   1) Model = Is the \"CEO\", which knows everything about the database stuff, connecting to database for example)\n\t   2) View = \"Sells stuff for custommers\" and works as a communicator in between (gets data from the model and tries to sell it to the controller)\n\t   3) Controller = \"Custommer who wants to buy stuff\" (where the users do their input and catch infos from the model)\n\n\u003cbr\u003e\n\u003cbr\u003e\n\n## \u0026nbsp;OOP with MVC: \"Kurz und knackig\" - \"Short and Crisp\" 🍪\n***\n**[GER]**\n\n- Alles wird in Objekte beschrieben\n- Jedes Objekt hat Eigenschaften\n- In den Eigentschaften speichern wir Daten in Form von Funktionalitäten (Methoden)\n- Prozesse zeigen wir mit Methoden auf.  Ein Haus z.B mit verkaufen() / abreissen() etc. || Methoden werden immer so dargestellt: Beispiel()\n\n**[ENG]**\n\n- Everything is described in OBJECTS\n- Each OBJECT has PROPERTIES\n- In properties we store data in the form of functionalities (METHODS)\n- We show processes with METHODS. A house, for example, with sell() / demolish() etc. || Methods are always represented like this: Example()\n\n\n\n\u003cbr\u003e\n\u003cbr\u003e\n\n## \u0026nbsp; !IMPORTANT: USEFUL TIPS: 🔥\n***\n\n**I) Use DOTS (.) to interrupt a string:** \n ```php\n$dsn = 'Blabla hello world' . $interruption . 'string goes on';\n```\n\n**II) Use BACKSLASH ( \\ ) before inverted commas ( \" ) to interrupt the closing of a string ( \\ \" ):** \n ```php\n$code .= \"\u003cp\u003e\u003ca href=\\\"movie.php?id=\".$out['id'].\"\\\"\u003eZum Film\u003c/a\u003e\u003c/p\u003e\";\n/*\n 1) \u003ca href=\"\" src=\"\" nuten auch Anführungszeichen! Setze ein \\ davor um den String nicht abzubrechen!\n 2) Wird ein String interrupted I) mit \". .\", so setzen wir KEIN \\ davor!\n */\n\n```\n\n**III) Pro tip: Use ( ' ) and ( \" ) to avoid taking care of Tip II) with ( \\ ):** \n ```php\n$code .= '\u003cp\u003e\u003ca href=\"movie.php?id=\".$out['id'].\"\"\u003eZum Film\u003c/a\u003e\u003c/p\u003e';\n```\n\n**IV) \u003c label \u003e and \u003c input \u003e - Who is who?** \n ```php\n\n \u003cdiv\u003e\n\t\u003clabel for=\"vorname\"\u003eVorname\u003c/label\u003e // for=\"\" des Labels zugehörig zur id=\"\" des Inputs\n\t\u003cinput type=\"text\" id=\"vorname\" name=\"vorname\" value=\"\u003c?=$vornameValue?\u003e\"\u003e\u003cbr\u003e // name=\"\" wichtig für Affenschwanz Duchgang / value=\"\" PHP Inhalte aus Datenbank anzeigen\n\u003c/div\u003e\n```\n\u003cbr\u003e\n\u003cbr\u003e\n\n## \u0026nbsp;OOP and PDO: Important TERMS in this WEBAPP_KUNGFU: 📈\n***\n| Term (word): |  Explenation:  | \n|:--------------| :--------------|\n|**\"INSTANZIERUNG\" -\u003e**| $instanz =\u003e \"Bauplan\" (Wichtig: Nach -\u003e NICHT Dollarzeichen verwenden, da Variable dadurch instanziert wird) |\n|**\"AUSGABE\"**| $ausgabe = Ausgabenvariable \"Fernseher\", um \"Bauplan\" durch Ausrufen der Instanz-\u003e anzuzeigen |\n|**\"new\"**| Instance a class from .class File to Main-File to create a new object (A) |\n|**PROCEDURAL PHP**| Regular PHP with tons of code with NO SEPERATE FILES AND CONCERNING TASKS vs: |\n|**OOP PHP with MVC**| Object Oriented Programming which uses a design pattern called Model View Controller |\n|**MVC - Model View Controller**| In OOP, we divide the code into certain areas / files: 1)=\u003e A model file (connecting to database) 2)=\u003e A view file (to show what the user has done) and 3)=\u003e A control area (where users do their input), and link them together. |\n|**PDO**| PHP Data Object, which helps to connect to database in OOP {{{ *PDO \u003e CRUD_beispiel / loginWithPDO* }}} (Top)= PDO \u003e MySQLi \u003e MySQL =(flop) |\n|**QUERIES**| Databaserequests. Be sure to use prepared statements to guarantee the maximum amount of safety! To run a query: prepare() \u003e bindParam() \u003e execute() |\n|**ARRAY**| Data structure that stores one or more similar type of values in a single name |\n|**CLASS (I)**| A OOP-package of Methods and Properties |\n|**METHOD (II) + (visability)**| A OOP-function ...() in a class {} (I) - Each method has an unique relation to the class you nested it inside of it {} |\n|**PROPERTY (III) + Visability:**| \"Eigenschaft in OOP\": A variable \"$\" in a class {} to capture a value in this variable + you HAVE TO define the visability as public, protected or private... |\n|**\"public\"**| Visability-Accessmodifier: \"The counter is open for all\" TIP: At first, set everything to Public to make sure your project works. |\n|**\"protected\"**| Visability-Accessmodifier: \"The counter is closed to the public, department among themselves can continue to operate\". With \"protected\", the superclass can \"lock the door\", the subclasses \"act as emergency keys\" |\n|**\"private\"**| Visability-Accessmodifier: With \"private\", access can neither be guaranteed via main and class files, nor via class inheritance. |\n|**$this** | $this-Keyword is used to call Methods (II) and Properties (III) in a class (I) \"Bauch der Instanzierung\" |\n|**OBJECT (A) with \"new\" in main-processing-document**| Instance (\"Instanzierung\") of a class with an allocated memory (\"Sammlung von Variablen\") in the MAIN FILE (index file) =\u003e We can define it as a \"BLUEPRINT\" |\n|**MEMBERS**| The \"called\" Methods (II) and Properties (III) in an object (A)|\n|**CONSTRUCTOR**| function __construct() =\u003e Konstruktor-Methode-Infrastrukur (\"Grundversorgung einer Methode\"(II)) am Anfang einer Klasse (Destructor = Am Ende einer Klasse) |\n|**INHERITANCE with:**| \"Vererbung\" with Superclasses (HEREDITARY = VERERBEND) and Subclasses (INHERITED = ERBEND) |\n|**SUPERCLASS \u003e SUBCLASS**| Subclasses are CHILDS, subordinated and inherited of their PARENTS,  known as Superclasses |\n|**EXTENDS**| Keyword: \"subclass of\" =\u003e class HUND extends HAUSTIER = Therefore: \"Hund ist eine Subklasse von Haustier\" |\n\n\u003cbr\u003e\n\u003cbr\u003e\n\n**1.1 METHODE (OHNE PROPERTIES) - EINE AUSGABE: --- [(Click HERE to view in folder)](https://github.com/Svendolin/Kungfu-App/tree/master/einstieg_OOP/einfache_klassen_beispielskripte) ---**\n```php\n/* ---- .CLASS FILE AUSGELAGERT ---- */\n\n// 0) METHODE definieren: Funktion \"rechne()\" in einer Klasse \"QuadratZahl1\"\n// Ausgelagert in .class-Ordner require(\"class/QuadratZahl1.class.php\");\nclass QuadratZahl1 {\n\n\t// +(Methode)+\n\tfunction rechne($anna) {\n\t\t$resultat = $anna * $anna;\n\t\treturn $resultat; // return, kein echo notwendig\n\t}\n}\n\n/* ---- MAIN FILE (PROCESSING FILE) ---- */\n\n// 0) Auf das ausgelagerte File zugreifen\nrequire(\"class/QuadratZahl1.class.php\");\n\n// 1) Object-Instanzierung (Instanz erhält mit \"new\"-Anweisung die Spezielkraft, Klasse wird mit seinem Namen instanziert)\n$instanz = new QuadratZahl1();\n\n// 1.1) OPT: var_dump() zeigt den Inhalt dieser Klasse auf\nvar_dump($instanz);\n\n// 2) Aufrufen in der Instanzvariable mit Parameter (hier 5) und als Ausgabevariable definieren für das spätere Echo\n$ausgabe = $instanz -\u003e rechne(5);\n\n/* ---- MAIN FILE HTML ---- */\n\n// 3) Als echo im HTML ausgeben\necho $ausgabe; // 25\n```\n\u003cbr\u003e\n\n**1.2 METHODE (OHNE PROPERTIES) - MEHRERE OBJEKT-AUSGABEN: --- [(Click HERE to view in folder)](https://github.com/Svendolin/Kungfu-App/tree/master/einstieg_OOP/einfache_klassen_beispielskripte) ---**\n```php\n/* ---- .CLASS FILE AUSGELAGERT ---- */\nclass QuadratZahl1 {\n\n\t// +(Methode)+\n\tfunction rechne($anna) {\n\t\t$resultat = $anna * $anna;\n\t\treturn $resultat; // return, kein echo notwendig\n\t}\n}\n\n/* ---- MAIN FILE ---- */\nrequire(\"class/QuadratZahl1.class.php\");\n\n// + (Object 1) +\n$instanz1 = new QuadratZahl1();\n$ausgabe1 = $instanz1 -\u003e rechne(5);\n\n// + (Object 2) +\n$instanz2 = new QuadratZahl1();\n$ausgabe2 = $instanz2 -\u003e rechne(8);\n\n// + (Object 3) +\n$instanz3 = new QuadratZahl1();\n$ausgabe3 = $instanz3 -\u003e rechne(15);\n\n/* MAIN FILE HTML */\necho \"Erste Ausgabe: \".$ausgabe1.\"\u003cbr\u003e\";\necho \"Zweite Ausgabe: \".$ausgabe2.\"\u003cbr\u003e\";\necho \"Dritte Ausgabe: \".$ausgabe3;\n```\n\u003cbr\u003e\n\n**1.3 METHODE - MIT PROPERTY (EIGENSCHAFT) und VALUE + public + $this + MEHREREN AUSGABEN: --- [(Click HERE to view in folder)](https://github.com/Svendolin/Kungfu-App/tree/master/einstieg_OOP/einfache_klassen_beispielskripte) ---**\n```php\n/* ---- .CLASS FILE AUSGELAGERT ---- */\nclass QuadratZahl2 {\n\t\n  // public-EIGENSCHAFT \"PROPERTY\" ist wie eine \"VOREINSTELLUNG\" in Variable $AntwortSatz. d.h:\n  // Wir geben im Bauch des Antwortsatzes automatisch diesen String mit:\n\n\t// +(Property mit Value)+ (Dieser String wird der DEFAULT-WERT sein von dieser property) \n\tpublic $AntwortSatz = \"Das Resultat ist: \"; \n\t\n\t// +(Methode)+\n\tfunction rechne($anna) {\n\t\t/* $this (Zugreifen, was innerhalb der Klasse definiert wurde)\n\t\t- Mit $this wird auf die Eigenschaft zugegriffen, die in allen Methoden sichtbar sind \n\t\t\t(\"Im Bauch der Methode suchen\")\n\t\t- Mit $this macht man einen Verweis auf das eigene Objekt aus der VOREINSTELLUNG\n\t\t- Beachte, dass das $-Zeichen vor \"AntwortSatz\" fehlt!!!\n\t\t*/\n\t\t$resultat = $this-\u003eAntwortSatz.$anna * $anna;\n\t\t\n\t\treturn $resultat;\n\t}\n}\n\n/* ---- MAIN FILE ---- */\nrequire(\"class/QuadratZahl2class.php\");\n\n$instanz = new QuadratZahl2();\n$ausgabe1 = $instanz -\u003e rechne(5); // \"rechne()\" kümmert sich um \"25\", public gibt den String mit\n$ausgabe2 = $instanz -\u003e AntwortSatz; // Hier geben wir nur den String mit\n\n/* ---- MAIN FILE HTML ---- */\necho $ausgabe1; // Das Resultat ist 25\necho $ausgabe2; // Das Resultat ist\n```\n\u003cbr\u003e\n\n**1.4 METHODE - MIT PROPERTY (EIGENSCHAFT) OHNE VALUE (ft. D.Krossing) ---**\n```php\n/* ---- Beispiel ---- */\n/* ---- .CLASS FILE AUSGELAGERT ---- */\n\n// +(Class)+\nclass Person {\n\t// +(Properties ohne default Wert)+\n\tpublic $name;\n\tpublic $eyeColor;\n\tpublic $age;\n\t\n\t// +(Methods)+\n\tpublic function setName($name) {\n\t\t$this-\u003ename = $name;\n\t}\n}\n\n/* ---- MAIN FILE ---- */\n\nrequire(\"class/...\");\n// +(Object)+\n\n$instanz = new Person();\n$ausgabe = $instanz -\u003e setName(\"Sven\"); \n\n/* ---- MAIN FILE HTML ---- */\necho $ausgabe; // Sven\n```\n\u003cbr\u003e\n\n**2.1 KONSTRUKTOR-METHODE: --- [(Click HERE to view in folder)](https://github.com/Svendolin/Kungfu-App/tree/master/einstieg_OOP/konstruktor__beispielskripte) ---**\n```php\n/* ---- .CLASS FILE AUSGELAGERT ---- */\nclass Konstruktiv {\n\n\t// +(Property)+ (Schlüsselwort Ausgabe)\n\tpublic $ausgabe;\n\n\t// +(Konstruktormethode)+ (Hier wird die GRUNDVERSORGUNG angegeben = WAS DAS OBJEKT ZUM ÜBERLEBEN BRAUCHT)\n\tfunction __construct() { // Immer mit 2x _ schreiben \n\t\t$string = \"Ich wurde geboren am \";\n\t\t$string .= date(\"d.m.y\").\" um \";\n\t\t$string .= date(\"H:i:s\");\n\t\t// Hier wird mit echo gearbeitet, dies jedoch nur aus didaktischen Gründen (KEIN RETURN)!!!\n\t\techo $string; // KEIN return sondern direkt das echo, wenn man __construct() verwendet\n\t}\n\n}\n\n/* ---- MAIN FILE ---- */\nrequire(\"class/Konstruktiv.class.php\");\n\n$instanz = new Konstruktiv();\n\n/* ---- MAIN FILE HTML ---- */\n// \"ausgabe\" NICHT $ausgabe nach -\u003e da instanziert\necho $instanz -\u003e ausgabe; // Ich wurde geboren am (Timestamp Datum) um (Timestamp Zeit)\n```\n\u003cbr\u003e\n\n**2.2 KONSTRUKTOR-METHODE MIT BRIEFKASTENVARIABLEN, WELCHE PARAMETER EMPFÄNGT: --- [(Click HERE to view in folder)](https://github.com/Svendolin/Kungfu-App/tree/master/einstieg_OOP/konstruktor__beispielskripte) ---**\n```php\n/* ---- .CLASS FILE AUSGELAGERT ---- */\nclass KonstruktivPara {\n\t\n\t// Die Konstruktormethode empfängt Parameter (Briefkastenvariablen reinschreiben)\n\n\t// +(Constructor-Method)+\n\tfunction __construct($param1,$param2) {\n\t\t$str = \"Guten Tag \";\n\t\t// Hier wird mit echo gearbeitet, dies jedoch nur aus didaktischen Gründen!!!\n\t\techo $str.$param1.\" \".$param2;\n\t}\n}\n\n/* ---- MAIN FILE ---- */\nrequire(\"class/KonstruktivPara.class.php\");\n// Die Konstruktormethode wird mit Parameter in Form von x2 Strings\"\" aufgerufen\n// Instanzierung mit new und Klassenname() (In $instanz ist der ganze Bauplan):\n$instanz = new KonstruktivPara(\"Peter\",\"Muster\");\n```\n\u003cbr\u003e\n\n**2.3 KONSTRUKTOR-METHODE MIT MEHREREN AUSGABEN: --- [(Click HERE to view in folder)](https://github.com/Svendolin/Kungfu-App/tree/master/einstieg_OOP/konstruktor__beispielskripte) ---**\n```php\n/* ---- .CLASS FILE AUSGELAGERT ---- */\nclass Kreisberechnung {\n\n\t// +(Properties)+\n\tpublic $flaeche = \"\";\n\tpublic $umfang = \"\";\n\t\n\t// +(Konstruktormethode)+\n\tfunction __construct($radius) {\n\t\t// Aufrufen der Hilfs-Methoden\n\t\t$this -\u003e flaeche = $this -\u003e calculateArea($radius);\n\t\t$this -\u003e umfang = $this -\u003e calculateCircumference($radius) ;\n\t}\n\t\n\t// Hilfs-Methode für das Berechnen der Kreisfläche\n\tpublic function calculateArea($r) {\n\t\t$fl = $r * $r * pi();\n\t\t$flGerundet = round($fl, 2);\n\t\t$flAntwort = \"Die Kreisflaeche betraegt: \".$flGerundet;\n\t\treturn $flAntwort;\n\t}\n\t\n\t// Hilfs-Methode für das Berechnen des Kreisumfangs\n\tpublic function calculateCircumference($r) {\n\t\t$um = 2 * $r * pi();\n\t\t$umGerundet = round($um, 2);\n\t\t$umAntwort = \"Der Kreisumfang betraegt: \".$umGerundet;\n\t\treturn $umAntwort;\n\t}\n}\n\n/* ---- MAIN FILE ---- */\nrequire(\"class/Kreisberechnung.class.php\");\n$instanz = new Kreisberechnung(5);\n// Lesen der Eigenschaften\n$ausgabe1 = $instanz -\u003e flaeche;\n$ausgabe2 = $instanz -\u003e umfang;\n\n/* ---- MAIN FILE HTML ---- */\necho $ausgabe1;\necho \"\u003cbr\u003e\";\necho $ausgabe2;\n```\n\u003cbr\u003e\n\n**3.1 VERERBUNG (INHERITANCE) SUPER- SUBKLASSENBEZIEHUNG: --- [(Click HERE to view in folder)](https://github.com/Svendolin/Kungfu-App/tree/master/einstieg_OOP/vererbung1_beispielskripte) ---**\n```php\n/* ---- ERSTES .CLASS FILE AUSGELAGERT (SUPERKLASSE) ---- */\n//  * Superklasse *\nclass Haustier {\n\t// Es hat drin: + Porperties (Eigenschaften) für ALLE Haustiere\n\tpublic $geschlecht;\n\tpublic $name;\n\tpublic $art;\n\t\t\n\t// Es hat drin: + Methode für ALLE Haustiere\n\tfunction WasBinIch() {\n\t\t$string = \"Über mich: Ich bin ein/e \";\n\t\t$string .= $this-\u003eart.\", \"; // $this = Referenz auf Objekt public $art\n\t\t$string .= \"ich heisse \".$this-\u003ename;\n\t\t$string .= \" und ich bin \".$this-\u003egeschlecht;\n\t\treturn $string;\n\t}\n}\n\n/* ---- ZWEITES .CLASS FILE AUSGELAGERT (SUBKLASSE) ---- */\n// Hier braucht's das Schlüsselwort \"extends\"\n// Somit ist diese Klasse HUND offiziell eine Subklasse von HAUSTIER\nclass Hund extends Haustier {\n\t\t\n\t// Diese METHODE gibt's NUR HIER, in der Subklasse\n\tfunction bellen() {\n\t\t$meineWoerter = \"Wuff, Wuff\";\n\t\treturn $meineWoerter;\n\t}\n}\n\n/* ---- MAIN FILE ---- */\nrequire(\"class/Haustier.class.php\");\nrequire(\"class/Hund.class.php\");\n\n// Instanziiert wird hier NUR DIE SUBKLASSE! - \"new Hund()\" reicht\n// Trotzdem stehen darauf die Mitglieder der Superklasse im Objekt zur Verfügung.\n$instanz = new Hund();\n\n// Eigenschaften schreiben, man beachte:\n// diese gehören zur Instanz der Subklasse, obwohl sie in der Superklasse definiert wurden!!!\n// Über die Instanz ansprechen:\n$instanz -\u003e geschlecht = \"männlich\";\n$instanz -\u003e name = \"Waldi\";\n$instanz -\u003e art = \"Hund\";\n\n// 1) Methode der SUPERKLASSE aufrufen, man beachte:\n// diese gehört zur Instanz der Subklasse, obwohl sie in der Superklasse definiert wurde!!!\n$ausgabe1 = $instanz -\u003e WasBinIch();\n\n// 2) Methode der SUBKLASSE aufrufen:\n$ausgabe2 = $instanz -\u003e bellen();\n\n/* ---- MAIN FILE HTML ---- */\necho $ausgabe1;\necho \"\u003cbr\u003e\";\necho $ausgabe2;\n```\n\u003cbr\u003e\n\n**3.2 VERERBUNG SICHTBARKEIT mit ACCESS MODIFIER PROTECTED an Methoden (WIRD AKZEPTIERT): --- [(Click HERE to view _4 in folder)](https://github.com/Svendolin/Kungfu-App/tree/master/einstieg_OOP/sichtbarkeit_beispielskripte) ---**\n\n\n* ((Kurz =\u003e \"Eltern schützen, Kind frei laufen lassen\")) \n```php\n/* ---- ERSTES .CLASS FILE AUSGELAGERT (PROTECTED-SUPERKLASSE) ---- */\n//  * Superklasse *\nclass SchatzkisteProtected {\n\n\tprotected function zeigeCodeFuerSchatz() { \n\t\t$source = \"\u003cimg src=\\\"bilder/treasurechest.png\\\"\u003e\";\n\t\treturn $source;\n\t}\n}\n\n/* ---- ZWEITES .CLASS FILE AUSGELAGERT (SUBKLASSE) ---- */\n//  * Subklasse *\n/* Hier definieren wir die Subklasse welche nicht geschützt ist ABER mit internem ZUGRIFF auf Superklasse */\nclass SchatzkisteKind extends SchatzkisteProtected {\n\n\tpublic function KindMethode() {\n\t\t// Aufruf einer Methode in der Superklasse, die mit protected definiert ist\n\t\t$raus = $this -\u003e ZeigeCodeFuerSchatz();\n\t\treturn $raus;\n\t}\n}\n\n/* ---- MAIN FILE ---- */\n\nrequire(\"class/SchatzkisteProtected.class.php\");\nrequire(\"class/SchatzkisteKind.class.php\");\n$instanz = new SchatzkisteKind();\n/* Zugriff auf eine öffentliche Methode der SUBKLASSE,\n   die (intern) auf eine Methode der Superklasse zugreift,\n   welche ihrerseits mit protected definiert ist:\n\t Sprich: Superklasse verschliesst die Tür, die Subklasse ist unser Notschlüssel! */\n$ausgabe = $instanz -\u003e KindMethode();\n\n/* ---- MAIN FILE HTML ---- */\necho $ausgabe;\n```\n\u003cbr\u003e\n\n**3.3 VERERBUNG SICHTBARKEIT mit ACCESS MODIFIER PRIVATE an Methoden (WIRD ABGEBLOCKT): --- [(Click HERE to view _5 in folder)](https://github.com/Svendolin/Kungfu-App/tree/master/einstieg_OOP/sichtbarkeit_beispielskripte) ---**\n```php\n/* ---- ERSTES .CLASS FILE AUSGELAGERT (SUPERKLASSE) ---- */\n//  * Superklasse *\nclass SchatzkistePrivate {\n\n\t/* Opt:\n\t- Ändere private zu protected, um die Subklasse zu schützen und den Error hier zu löschen! Somit kann die Subklasse \t           ihren part übernehmen\n\t- Ändere private zu public, so wird die Superklasse direkt ausgeführt und die Subklasse wäre eigentlich hinfällig\n\t*/\n\tprivate function zeigeCodeFuerSchatz() { \n\t\t$source = \"\u003cimg src=\\\"bilder/treasurechest.png\\\"\u003e\";\n\t\treturn $source;\n\t}\n}\n\n/* ---- ZWEITES .CLASS FILE AUSGELAGERT (SUBKLASSE) ---- */\n//  * Subklasse *\n// Hier braucht's ebenfalls das Schlüsselwort \"extends\"\n/class SchatzkisteKind2 extends SchatzkistePrivate {\n\n\tpublic function KindMethode() {\n\t\t// Aufruf einer Methode in der Superklasse SchatzkistePrivate, die mit private definiert ist\n\t\t// Dies schlägt fehl\n\t\t$raus = $this -\u003e ZeigeCodeFuerSchatz();\n\t\treturn $raus;\n\t}\n}\n\n/* ---- MAIN FILE ---- */\n\nrequire(\"class/SchatzkistePrivate.class.php\"); // Auslagerung der Superklasse (set to private)\nrequire(\"class/SchatzkisteKind2.class.php\"); // Auslagerung der Subklasse (set to public)\n$instanz = new SchatzkisteKind2();\n// 1) Zugriff auf eine öffentliche Methode der Subklasse SchatzkisteKind2...\n// 2) ...die (intern) auf eine Methode der Superklasse SchatzkistePrivate zugreift...\n// 3) ...welche ihrerseits mit private definiert ist.\n// 4) Das schlägt fehl! Der Notschlüssel\n$ausgabe = $instanz -\u003e KindMethode();\n\n/* ---- MAIN FILE HTML ---- */\necho $ausgabe;\n```\n\u003cbr\u003e\n\n**3.4 Wie kann man den ACCESS MODIFIER private korrekt anwenden? --- [(Click HERE to view _6 in folder)](https://github.com/Svendolin/Kungfu-App/tree/master/einstieg_OOP/sichtbarkeit_beispielskripte) ---**\n```php\n/* ---- .CLASS FILE AUSGELAGERT ---- */\nclass SchatzkistePrivatePlus {\n\t// Properties kann man mit Sichtbarkeit schalten, METHODEN enbenfalls!\n\t// Somit setzen wir die ertse Methode auf PRIVATE...\n\tprivate function zeigeCodeFuerSchatz() {\n\t\t$source = \"\u003cimg src=\\\"bilder/treasurechest.png\\\"\u003e\";\n\t\treturn $source;\n\t}\n\t// ...und die zweite Methode auf PUBLIC:\n\t// Innerhalb der KLASSE kann auf die obige Methode zugegriffen werden, auch wenn diese mit private definiert ist:\n\tpublic function zweiteMethode() {\n\t\t$sourceVonOben = $this -\u003e zeigeCodeFuerSchatz();\n\t\treturn $sourceVonOben;\n\t\n\t}\n}\n\n/* ---- MAIN FILE ---- */\n\nrequire(\"class/SchatzkistePrivatePlus.class.php\");\n$instanz = new SchatzkistePrivatePlus();\n// Zugriff auf eine öffentliche Methode,\n// die (intern) auf eine andere Methode der gleichen Klasse zugreift,\n// welche ihrerseits mit private definiert ist\n$ausgabe = $instanz -\u003e zweiteMethode();\n\n/* ---- MAIN FILE HTML ---- */\necho $ausgabe;\n```\n\u003cbr\u003e\n\n## \u0026nbsp;PDO: Execute Queries = prepare - bind - execute 💡\n***\n\n**1.1. Arbeiten mit CRUD Statements via PDO (Verbindung zur Datenbank) --- [(Click HERE to view folder)](https://github.com/Svendolin/Kungfu-App/tree/master/PDO/CRUD_beispiel) ---**\n```php\n/* Localhost siehe: http://localhost/OOP/webapp_kungfu/PDO/CRUD_beispiel/create.php (Create ist hier der \"index.php\") */\n\n// Welche Funktionen haben die Files?\n\n* SimpleCRUD.class.php = Verwaltungsfile von Klassen und Methoden [prepare() \u003e bindParam() \u003e execute()] + PDO Datenbankzugriff\n* credentials.php = Datenbankangaben\n* create.php = Index.php File mit Inputfelder [CRUD = Create]\n* read.php = Lesefile [CRUD = Read]\n* read_erweitert.php = Tabelle mit [CRUD = Read, Update, Delete]\n* update.php = Update mit ID, wenn User fon read_erweitert.php auf UDPATE klickt [CRUD = Update]\n```\n\u003cbr\u003e\n\n**1.2. Beispiel eines simplen Logins (sign in) OHNE Registrierung (no sign up)  --- [(Click HERE to view folder)](https://github.com/Svendolin/Kungfu-App/tree/master/PDO/loginWithPDO) ---**\n```php\n/* Localhost siehe: http://localhost/OOP/webapp_kungfu/PDO/loginWithPDO/login_form.php (login_form ist hier der \"index.php\") */\n\n// Welche Funktionen haben die Files?\n\n* SimpleCRUD.class.php = Verwaltungsfile von Klassen und Methoden [prepare() \u003e bindParam() \u003e execute()] + PDO Datenbankzugriff\n* credentials.php = Datenbankangaben\n* login_form.php = Index.php File quasi, Login-Formular mit Inputfelder \n* login_tabelle.sql = Datenbankformular, wo 2 Nutzer bereits erstellt sind, siehe: test_user.txt\n* success.php = Privater Bereich, falls Login erfolgreich\n\n// Falls man PASSWÖRTER HASHEN möchte...\n\n1) Im Browser anzeigen lassen:\necho password_hash(\"YourPasswordHere\", PASSWORD_DEFAULT); \n\n2) Rauskommentieren und Username sowie Passwort aufschreiben\n3) Passender Hash zum Passwort wird zur SQL-Liste hinzugefügt\n```\n\u003cbr\u003e\n\n\u003cbr\u003e\n\u003cbr\u003e\n\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsvendolin%2Fkungfu-app","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsvendolin%2Fkungfu-app","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsvendolin%2Fkungfu-app/lists"}