www.webdeveloper.com
Results 1 to 3 of 3

Thread: Convert into oop php

  1. #1
    Join Date
    Mar 2014
    Posts
    63

    Convert into oop php

    can any one help to convert this into oop i am using this function in the class...

    function check($Data){
    // sql injection
    $Data = trim($Data);
    $Data = stripslashes($Data);
    $Data = htmlspecialchars($Data);
    return $Data;
    }

    //usage
    $name=$Object-> check($_POST["name"]);

  2. #2
    Join Date
    Mar 2014
    Posts
    3
    PHP Code:
    class checking_stuff {
      public function 
    check($data) {
        
    $data trim($data);
        
    $data stripslashes($data);
        
    $data htmlspecialchars($data);
        return 
    $data;
      }
    }
    $obj     = new checking_stuff();
    $check $obj->check('something_here'); 

  3. #3
    Join Date
    Aug 2004
    Location
    Ankh-Morpork
    Posts
    19,175
    Of course, a class with a single method and no data attributes is no more object-oriented than that method existing instead as a stand-alone function.
    "Please give us a simple answer, so that we don't have to think, because if we think, we might find answers that don't fit the way we want the world to be."
    ~ Terry Pratchett in Nation

    eBookworm.us

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles