Object Oriented Programming Tutorial PHP Class File Creation Learn OOP

Object Oriented Programming Tutorial PHP Class File Creation Learn OOP

Listening Video

Learn Object Oriented Programming (OOP) in PHP. OOP is used to tap into class files that house your software logic in an organized, extensible, dynamic, reusable framework of sorts. You can use class files to create very robust custom frameworks in PHP. JavaScript and ActionScript 3.0 have similar flow to PHP so it also is easy to make external reusable modules for those languages as well. I also threw in a PHP bad word filter function, so you get a bit of string manipulation logic and array handling thrown in for free.
Lesson Code
<!-- curseFilter.php -- CLASS FILE -->

<?php
class curseFilter {
function clean($str){
    $curzwords = array("jerk","buttface","idiot");
        $replacers = array("j**k","cuteface","id**t");
        $cleanStr = str_ireplace($curzwords, $replacers, $str);
    return $cleanStr;
    }
}
?>

<!-- example.php -- DEMO USAGE FILE -->

<?php
include_once("curseFilter.php");
$curseFilter = new curseFilter;
// -----------------------
$string = "you jerky idiot.";
$clean_str = ($curseFilter -> clean($string));
echo $clean_str;
?>

0 Response to "Object Oriented Programming Tutorial PHP Class File Creation Learn OOP"

Post a Comment