<?php class FileInfoTest extends PHPUnit_Framework_TestCase { protected $fileWithExtension; protected $fileWithoutExtension; public function setUp() { $this->fileWithExtension = new \Upload\FileInfo(dirname(__FILE__) . '/assets/foo.txt', 'foo.txt'); $this->fileWithoutExtension = new \Upload\FileInfo(dirname(__FILE__) . '/assets/foo_wo_ext', 'foo_wo_ext'); } public function testConstructor() { $this->assertAttributeEquals('foo', 'name', $this->fileWithExtension); $this->assertAttributeEquals('txt', 'extension', $this->fileWithExtension); $this->assertAttributeEquals('foo_wo_ext', 'name', $this->fileWithoutExtension); $this->assertAttributeEquals('', 'extension', $this->fileWithoutExtension); }
We know that in the process of using the language, we will definitely pay attention to the security issues in the actual development process. So, today we will introduce to you the primary measure to ensure PHP security-verification data. Validation of data is the most important habit you can adopt. And when it comes to input, it's very simple: don't trust the user. When validating data to secure PHP, remember that it's often easier to design and validate the values your application allows than to protect against all unknown values.
General validation tips that apply to various types of validation data are listed below:
1. Use values from the whitelist
2. Always re-validate limited options
3. Use the built-in escape function
4. Verify that the correct data type (such as a number)
The value in the white-listed value (White-listed value) is the correct value , as opposed to an invalid blacklist value (Black-listed value). The difference between the two is that typically when validating data, the list or range of possible values is smaller than the list or range of invalid values, many of which may be unknown or unexpected values.
All resources on this site are contributed by netizens or reprinted by major download sites. Please check the integrity of the software yourself! All resources on this site are for learning reference only. Please do not use them for commercial purposes. Otherwise, you will be responsible for all consequences! If there is any infringement, please contact us to delete it. Contact information: admin@php.cn
Related Article
29Jul2016
PHP file, file upload: Implementation and introduction of PHP file upload: The implementation and introduction are in the program comments. Page to submit files: (can be submitted to doAction.php, doAction1.php, doAction2.php respectively for testing) upload.php file upload
02Dec2024
Upload Files with Java HttpClient and PHPIn this scenario, you're attempting to upload a file to Apache with PHP using the Java HttpClient library...
19Jul2024
Pydantic is a Python library that simplifies data validation using type hints. It ensures data integrity and offers an easy way to create data models with automatic type checking and validation. In software applications, reliable data validation is
17Jul2023
How to use Vue and ElementPlus for form validation and data processing Introduction: In web development, form validation and data processing are very important. Vue is a popular JavaScript framework, and ElementPlus is a Vue-based UI component library. Their combination can effectively simplify the process of form validation and data processing. This article will introduce how to use Vue and ElementPlus to implement form validation and data processing, and give relevant code
17Nov2024
PHP Email Address Validation Library InquiryValidating email addresses is essential to ensure data integrity. However, creating a compliant...
Hot Tools
PHP common form validation classes
PHP common form validation classes
PHP code to implement form data validation class library
PHP code to implement form data validation class library
validationdata validation library
validationdata validation library
Fully functional php validation class
Fully functional php validation class
validation-Laravel's validation library
validation-Laravel's validation library