1. Go to this page and download the library: Download cecostadev/check-type library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
cecostadev / check-type example snippets
pp\Core\CheckType;
// Instantiate the CheckType class
$checkType = new CheckType();
// Define the file type to validate
$fileType = 'png';
// Validate if the file type is a supported image
if ($checkType->validateImage($fileType)) {
echo "Valid Image.";
} else {
echo "Invalid Image.";
}
pp\Core\CheckType;
// Instantiate the CheckType class
$checkType = new CheckType();
// Define the file type to validate
$fileType = 'pdf';
// Validate if the file type is a supported document
if ($checkType->validateDocument($fileType)) {
echo "Valid Document.";
} else {
echo "Invalid Document.";
}
pp\Core\CheckType;
// Instantiate the CheckType class
$checkType = new CheckType();
// Add a new category 'audio' with supported file extensions
$checkType->addCategory('audio', ['mp3', 'wav']);
// Define the file type and category to validate
$fileType = 'mp3';
$category = 'audio';
// Validate if the file type belongs to the 'audio' category
if ($checkType->validateByCategory($fileType, $category)) {
echo "Valid Audio File.";
} else {
echo "Invalid Audio File.";
}
pp\Core\CheckType;
// Instantiate the CheckType class
$checkType = new CheckType();
// Define the file type and a custom list to validate against
$fileType = 'gif';
$customList = ['gif', 'bmp', 'tiff'];
// Validate if the file type is within the custom list
if ($checkType->validate($fileType, $customList)) {
echo "File type is valid within the custom list.";
} else {
echo "File type is not valid within the custom list.";
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.