PHP code example of padosoft / support
1. Go to this page and download the library: Download padosoft/support 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/ */
padosoft / support example snippets
ump(str_random(16));
/*
* constans
*/
echo 'directory separator is: '.DS;
/*
* validation helpers
*/
//check iso date
if( !isDateIso("") ) echo 'invalid.';
if( !isDateIso("2016-08-18") ) echo 'invalid.';
if( !isDateIso("2016-18-08") ) echo 'invalid.';
if( !isDateIso("0000-00-00") ) echo 'invalid.';
if( !isDateIso("00-00-00") ) echo 'invalid.';
if( !isDateIso("16-08-18") ) echo 'invalid.';
if( !isDateIso("2016-02-38") ) echo 'invalid.';
//check italian Fiscal Code
if( !isCf("") ) throw new Exception();
if( !isCf("abcdefghijklmnoz") ) throw new Exception();
if( !isCf("xxxxxx12c34x567o") ) throw new Exception();
//check italian VAT (Partita iva)
if( !isPiva("") ) throw new Exception();
if( !isCf("00000000000") ) throw new Exception();
if( !isCf("02361141209") ) throw new Exception();
if( !isCf("00000000001") ) throw new Exception();
//check integer value
if( !isInteger(1561) ) throw new Exception();
if( !isInteger('sadasd') ) throw new Exception();
/*
* datetime helpers
*/
//sleep 2 minuti
sleep(2*MINUTE_IN_SECOND);
//sleep 2h
sleep(2*HOUR_IN_SECOND);
//sleep 2min and 30seconds
sleep(2*MINUTE_IN_SECOND+30);
//date format
echo date(DATE_FORMAT_ISO);//'Y-m-d'
echo date(DATE_FORMAT_ITA);//'d-m-Y'
echo date(DATE_TIME_FORMAT_ISO);//'Y-m-d H:i:s'
//date conversion
echo dateIsoToIta('2016-08-18');//08/18/2016
//days and month
echo DAYS_ITA_ARR[0];//Lunedi
echo DAYS_ITA_ARR[date('w')];
echo MONTHS_ITA_ARR_1_BASED[12];//Dicembre
echo MONTHS_ITA_ARR_1_BASED[date('j')];
//misc
echo roman_year(50);//L
echo roman_year(10);//X
echo roman_year(2000);//MM
echo roman_year(2016);//MMXVI
/**
* String
*/
echo str_random(16);