Skip to content

Instantly share code, notes, and snippets.

View alexlatam's full-sized avatar
🏠
Working from home

Alexis Montilla alexlatam

🏠
Working from home
View GitHub Profile
@alexlatam
alexlatam / dates.php
Last active July 23, 2024 22:18
PHP Dates
<?php
// https://www.php.net/manual/es/refs.calendar.php
echo date("Y/m/d"); // Current date on format: 2024/12/24
echo date("Y-m-d"); // Current date on format: 2024-12-24
echo date("h:i:sa"); // Current hour on format: 04:33:39am
echo date("h:i:s"); // Current hour on format: 04:33:39
echo date("H:I:s"); // Current hour on format: 20:33:39
echo date('Y-m-d H:i:s'); // Current date: 2024-07-23 12:34:56
@alexlatam
alexlatam / filter_var.php
Created July 23, 2024 05:19
Filter and sanitize data with PHP
<?php
// VALIDATIONS
filter_var($integerNumber, FILTER_VALIDATE_INT); // verify if variable is an integer number
filter_var("127.0.0.1", FILTER_VALIDATE_IP); // verify if is an IP code
filter_var("[email protected]", FILTER_VALIDATE_EMAIL); // verify if is a correct email
filter_var("https://domain.ext/", FILTER_VALIDATE_URL); // verify if is a correct url
filter_var("true", FILTER_VALIDATE_BOOLEAN, FILTER_NULL_ON_FAILURE); // verify if is a boolean value
filter_var("123.45", FILTER_VALIDATE_FLOAT); // verify if is a float number
//SANITIZE DATA
@alexlatam
alexlatam / ftp.php
Created July 23, 2024 05:27
FTP Connection using PHP
<?php
// Session data
$ftpHost = 'ftp.domain.ext';
$ftpUsername = 'username';
$ftpPassword = '*****';
// Connect with ftp host
$conn = ftp_connect($ftpHost) or die("Is not possible connect with ftp host");