This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
trim_trailing_whitespace = true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
private function _logfile($logName, $str2log) | |
{ | |
$file= sys_get_temp_dir() . '/mydebug-' . date('Y-m-d') . '.log'; | |
if (!$handle = fopen($file, 'a')) { | |
throw new Exception('Could not open file!'); | |
} | |
$str2log = print_r($str2log, true); | |
$olog = print_r("{$logName}: {$str2log}", true) . PHP_EOL; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Seach in array value, similar to in_array(), but has ability to search with partial match | |
* @param string $needle searched value | |
* @param array $haystack target array | |
* @param string $return_key if third parameter is set to TRUE, the function will return array key | |
* @return boolean|int|string if found, function will return TRUE, string or int of first founded key (if return_key set to TRUE) | |
* otherwise FALSE | |
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Escape php string to javascript string | |
* @param string $str | |
* @return string escaped string | |
*/ | |
function escape_javascript_string($str){ | |
// if php supports json_encode, use it (support utf-8) | |
if (function_exists('json_encode')) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Convert number with unit byte to bytes unit | |
* @link https://en.wikipedia.org/wiki/Metric_prefix | |
* @param string $value a number of bytes with optinal SI decimal prefix (e.g. 7k, 5mb, 3GB or 1 Tb) | |
* @return integer|float A number representation of the size in BYTES (can be 0). otherwise FALSE | |
*/ | |
function str2bytes($value) { | |
// only string |
NewerOlder