Posts

php formated Print statement

$num  =  5 ; $location  =  'tree' ; $format  =  'There are %d monkeys in the %s' ; echo  sprintf ( $format ,  $num ,  $location );

PHP Implode and explode

$array = array('lastname', 'email', 'phone');   $comma_separated = implode(",",$array);  echo $comma_separated; // lastname,email,phone   =================================================   $pizza = "piece1 piece2 piece3 piece4 piece5 piece6";   $pieces = explode(" ", $pizza);   echo $pieces[0]; // piece1 echo $pieces[1]; // piece2

Make tar file exclude folder using command line

tar -czf backupname.tgz --exclude="/app/www/xyz" /app/www/

PHP - file mode permission

chmod("/dir/file.txt", 0755);

Linux command line search and replace string in all files

String Find and replace (folders/sub folders) > grep -rl "old string" . | xargs sed -i 's/old string/new string/g' URL Find and replace (folders/sub folders) > grep -rl "www\.google\.com" . | xargs sed -i 's/www\.google\.com/www\.yahoo\.com/g' Find string > grep -iRl "search string" /path/lcoation

PHP ERROR Reporting

ini_set('display_errors', 1); ini_set('display_startup_errors', 1); error_reporting(E_ALL);