<?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
06Jul2016
Is there a PHP open source system like piwigo that supports psd upload and generate thumbnails? After using piwigo to build a picture sharing system, I found two problems: 1. The picture is too long and thumbnails cannot be generated. 2. The psd uploaded by ftp cannot generate thumbnails.
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...
19Dec2024
Uploading a File via Java's HttpClient with PHPIn an attempt to upload a file from Java to an Apache server utilizing PHP, a Java application was...
17Nov2024
PHP Email Address Validation Library InquiryValidating email addresses is essential to ensure data integrity. However, creating a compliant...
17Oct2024
Easiest Form Validation Library for PHPProblem:Developing a straightforward PHP library for efficient form validation, where rules and field names can be easily passed and errors retrieved.Answer:One approach is to implement your own validation class
26Nov2024
Validating Email Addresses in PHP: Open-Source Library or Built-In Function?Email address validation is crucial to ensure accurate data collection...
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