Here's a simple function to generate a random string based on Alpha, Numeric, Nozero, MD5 and SHA1 types.
PHP reverse function strrev() and it's alternative
If you ever wondered how to reversing a string using PHP reverse function “strrev()” and write your own function doing the same thing? Oddly I was asked to write my own PHP function to reverse a string and I though to sharing it.
PHP Header() Function - Force header for a file to download in PHP
This either in PHP will help you to sends the files:
<?php
$file = 'folder/yourfile.zip' ; //Any file *.*
if (! file) {
die('file not found'); //Or do something
} else {
// Set headers
header("Cache-Control: public");
header("Content-Description: File Transfer");
header("Content-Disposition: attachment; filename=$file");
header("Content-Type: application/octet-stream");
header("Content-Transfer-Encoding: binary");
// Read the file from disk
readfile($file);
}
?>Simple PHP Text Limiter Function
This function will limited a text string to a given word limit.
<?php
function string_limiter($string, $limit = 50, $end_char = '…')
{
if (trim($string) == '')
{
return $string;
}
preg_match('/^\s*+(?:\S++\s*+){1,'.(int) $limit.'}/', $string, $matches);
if (strlen($string) == strlen($matches[0]))
{
$end_char = '';
}
return rtrim($matches[0]).$end_char;
}
?>Example:
How to find file or folder location in Linux/Unix usnig bash command line
Use this grep commend
locate apache | egrep "\/apache$"
Example:
[myserver]$: locate apache | egrep "\/apache$"
[myserver]$: /usr/local/dh/apache
[myserver]$: /usr/local/dh/apache