Welcome to Code Forum!

Join a community that supports you and your coding journey from day one. We strive to be a friendly, supportive community that empowers everyone to be better developers. By registering with us, you'll be able to discuss, share and private message with other members of our community.

SignUp Now!
  • Guest, before posting your code please take these rules into consideration:
    • It is required to use our BBCode feature to display your code. While within the editor click < / > or >_ and place your code within the BB Code prompt. This helps others with finding a solution by making it easier to read and easier to copy.
    • You can also use markdown to share your code. When using markdown your code will be automatically converted to BBCode. For help with markdown check out the markdown guide.
    • Don't share a wall of code. All we want is the problem area, the code related to your issue.

    GIF shows where to locate </> in the thread and or post editor toolbar.
    To learn more about how to use our BBCode feature, review our "How to post your code into threads" here.

    Thank you, Code Forum.

PHP How to install and use PhpSanitization

fariscode

New Coder
Hey CodeForum Members.

In this simple article, I will explain how to install and use PhpSanitization.

But I will tell you what is PhpSanitization how can it help you.

What is PhpSanitization​

PhpSanitization is a simple class that can verify and clean values to assure they are valid.

It can take a given string and remove or encode certain types of text values, so it can be displayed on Web pages lowering the risk of being used to perform security attacks.

The class can also sanitize arrays of data by processing the array values one by one.

Features​

1. Out-Of-The-Box.
2. Support String, Arrays, and Associative Arrays.
3. Escape PDO and SQL queries.
4. Easy to Use.

How to Install​

First, you need to install the composer before installing it.

You can install Composer simply from here Composer.

[CODE lang="bash" title="Composer Installer"]php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
php -r "if (hash_file('sha384', 'composer-setup.php') === '756890a4488ce9024fc62c56153228907f1545c228516cbf63f885e036d37e9a59d27d63f46af1d4d07ee0f76181c7d3') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;"
php composer-setup.php
php -r "unlink('composer-setup.php');"[/CODE]

After installing composer now you will be able to install PhpSanitization.

Cd to your project folder using the terminal after that use this command to install the project using composer.

Bash:
composer require phpsanitization/phpsanitization

How to use​

The usage of the project is simple.

In your form handler add this block of code to sanitize any POST request.

PHP:
include_once 'vendor/autoload.php';

use PhpSanitization\PhpSanitization\Sanitization;

$s = new Sanitization();

$post = $s->useSanitize($_POST);

Documentation​

The documentation for PhpSanitization is available here.

In the End​

If you have any idea or like to contribute please do.

Download​

To download the project source code from here.
 

Buy us a coffee!

Buy me a coffee.
Back
Top Bottom