Skip to content

Instantly share code, notes, and snippets.

View NewEXE's full-sized avatar
🌀
WIP

Vlad Voloshyn NewEXE

🌀
WIP
  • Sweet Stack Digital
  • Ukraine, Kharkiv
View GitHub Profile
@NewEXE
NewEXE / index.php
Last active August 18, 2021 23:55
Convert anything to string (PHP)
<?php
/**
* @param mixed $value Value of any PHP type.
* @return string Value as readable string.
*/
function toString($value, $compactArray = true): string
{
$data_type = '';
if (is_array($value)) {
@NewEXE
NewEXE / index.php
Last active May 12, 2020 10:00
PHP random funtion
<?php
// From old versions of Laravel
// Don't use in cryptography
function str_random($length = 16)
{
$pool = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
return substr(str_shuffle(str_repeat($pool, $length)), 0, $length);
}
@NewEXE
NewEXE / test1.php
Last active September 15, 2018 20:19
PDO Memory Leak
<?php
// Related SO disscussion:
// https://stackoverflow.com/questions/52348483/pdo-mysqli-memory-leak-on-multiple-select-queries
$dbParams = [
'host' => 'localhost',
'dbname' => 'playground',
'username' => 'homestead',
'password' => 'secret',
];