Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6187883
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T02:08:08+00:00 2026-05-24T02:08:08+00:00

again with another problem. public function __construct() { $_GET = $this->clean($_GET); $_POST = $this->clean($_POST);

  • 0

again with another problem.

public function __construct() {
    $_GET = $this->clean($_GET);
    $_POST = $this->clean($_POST);
    ...

}

public function clean($data) {
    if (is_array($data)) {
        foreach ($data as $key => $value) {
            unset($data[$key]);

            $data[$this->clean($key)] = $this->clean($value);
        }
    } else { 
        $data = htmlspecialchars($data, ENT_COMPAT, 'UTF-8');
    }

    return $data;
}

i dont understand why $data[$this->clean($key)] = $this->clean($value); is calling its own function. what is the point of doing this? the advantages

thanks,
daniel

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T02:08:09+00:00Added an answer on May 24, 2026 at 2:08 am

    It’s a technique called recursion. This particular function descends into the structure until it is dealing with very simple data and sanitizes it all.

    Given this:

    $arr = array (
       '<foo' => array(
           'bat' => 'OMGWTFBBQ!!><!?!'
       ),
       'bar' => 'baz'
    );
    

    It would start:

    1. is arr an array?
      1. is <foo an array? (no)
        • <foo becomes &lt;foo
        • &lt;foo used as a key
      2. is the value of <foo an array? (yes)
        1. Is bat an array? (no)
          • bat remains as is (still has htmlspecialchars called, but it does not change anything))
        2. Is 'OMGWTFBBQ!!><!?!' an array (no)?
          • 'OMGWTFBBQ!!><!?!' is converted to 'OMGWTFBBQ!!&gt;&lt;!?!'
          • 'OMGWTFBBQ!!&gt;&lt;!?!' is used for the value for bat.
      3. Is ‘bar’ an array? (no)
        1. bar returned as is (like bat above)
        2. Is baz an array? (no)
          • baz returned as is.

    You can think of it this way

    $arr = array (
       '<foo' => array(
           'bat' => 'OMGWTFBBQ!!><!?!'
       ),
       'bar' => 'baz'
    );
    
    ///////////////////////////////////////////
    array (
       clean('<foo') => array(
           'bat' => 'OMGWTFBBQ!!><!?!'
       ),
       'bar' => 'baz'
    );
    
    ///////////////////////////////////////////
    array (
       '&lt;foo' => clean( array(
           'bat' => 'OMGWTFBBQ!!><!?!'
       )),
       'bar' => 'baz'
    );
    
    ///////////////////////////////////////////
    array (
       '&lt;foo' => array(
           clean( 'bat' ) => 'OMGWTFBBQ!!><!?!'
       )),
       'bar' => 'baz'
    );
    
    ///////////////////////////////////////////
    array (
       '&lt;foo' => array(
           'bat' => clean( 'OMGWTFBBQ!!><!?!' )
       )),
       'bar' => 'baz'
    );
    
    ///////////////////////////////////////////
    array (
       '&lt;foo' => array(
           'bat' => 'OMGWTFBBQ!!&gt;&lt;!?!'
       )),
      clean( 'bar' ) => 'baz'
    );
    ///////////////////////////////////////////
    array (
       '&lt;foo' => array(
           'bat' => 'OMGWTFBBQ!!&gt;&lt;!?!'
       )),
      'bar' => clean( 'baz' )
    );
    ///////////////////////////////////////////
    return array (
       '&lt;foo' => array(
           'bat' => 'OMGWTFBBQ!!&gt;&lt;!?!'
       )),
      'bar' => 'baz'
    );
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

provisioning problem again. Refering to my question: iPhone Development Provisioning Assistant Step 3 public/private
another day, another problem. Honestly, it would be rather boring if this ever stopped,
After getting the right answer from this question , I am having another problem
Again I have a question regarding this plugin: http://t.wits.sg/2008/06/20/jquery-progress-bar-11/ What I want to achieve
I've got 3 files that relate to this problem. file.h, file.C and user.C. file.h
i know this should be simpel and im probably staring straight at the problem
I have hit another wall. After getting my key input working, I have been
I have an interesting problem.. I have a Form that launches another Form (2)
My problem is this: Google App Engine allows cron jobs to be active for
I have got this event in my page aspx.cs: public void deleteBtn_Click(object sender, CommandEventArgs

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.