Showing posts with label trick. Show all posts
Showing posts with label trick. Show all posts

Friday, August 3, 2018

Create Auto Backup Database on Linux


apt-get install cron

crontab -e

#!/bin/sh
 mysqldump -u root -pQidDniuJMb@LC@G5 gift > /var/bin/db/gift/gift.sql
 cd /var/bin/db/gift/
 tar -zcvf giftsql_$(date +%d%m%y).tgz *.sql
 find -name '*.tgz' -type f -mtime +2 -exec rm -f {} \;

0 * * * * /var/bin/mysqlbackup.sh


*/3 * * * * /var/bin/executedb.sh

Wednesday, March 23, 2016

Some Useful PHP Tricks You May Not Know

After I read many articles, I found some cool tricks in PHP that are very useful for our projects. Please have a look at 5 tricks below you may satisfy with them.



1. Array in Form Fields

Not only the form input fields that create array like
<input name="name['fullname']">
but you can create arrays with checkboxes also.

<label><input type="checkbox" name="hobbies[]" value="Sports" /> Sports</label><br />
<label><input type="checkbox" name="hobbies[]" value="Hiking" /> Hiking</label><br />
<label><input type="checkbox" name="hobbies[]" value="Swimming" /> Swimming</label><br />
<label><input type="checkbox" name="hobbies[]" value="Swimming" /> Watching Movies</label><br />

2. Count Character in a String

When you want to count the string you will think about strlen() function. However, we have a fastest way to count it. Take a look at the following code:

$string = 'testing';

if(isset($string[6]))
 echo "The string '$string' is at least 7 characters long.";
else
 echo "The string '$string' is less than 7 characters long.";

You treated $string like an array.

3. Use PHP Echo like a Boss

Most of the time we always thought that if we want to concatenate strings with echo, we need to use period. But we can use echo like a function that can replace period with commas instead. Please look at the fastest way to do so:
$string1 = 'test-string1';
$string2 = 'test-string2';
$string3 = 'test-string3';

echo 'String #1: ', $string1, '
'; echo 'String #2: ', $string2, '
'; echo 'String #3: ', $string3, '
';
You will find some more useful trick anywhere else, but these cool tricks is for you. Good luck!

Tuesday, March 22, 2016

phpDesigner 8 Best IDE for Your Next PHP Projects

phpDesigner 8 is a fast PHP IDE and PHP editor with built-in HTML5-, CSS3- and JavaScript editors boosted with features to help you create amazing websites. phpdesigner



The main pro of this one is that it's NOT Java based. This keeps the whole thing quick.

Features:

  • Intelligent Syntax Highlighter - automatic switch between PHP, HTML, CSS, and JavaScript depending on your position!
  • PHP (both version 4 and 5 are supported)
  • SQL (MySQL, MSSQL 2000, MSSQL 7, Ingres, Interbase 6, Oracle, Sybase)
  • HTML/XHTML
  • CSS (both version 1 and 2.1 are supported)
  • JavaScript
  • VBScript
  • Java
  • C#
  • Perl
  • Python
  • Ruby
  • Smarty

PHP:

  • Support for both PHP 4 and PHP 5
  • Code Explorer for PHP (includes, classes, extended classes, interfaces, properties, functions, constants and variables)
  • Code Completion (IntelliSense) for PHP - code assist as you type
  • Code Tip (code hint) for PHP - code assist as you type
  • Work with any PHP frameworks (access classes, functions, variables, etc. on the fly)
  • PHP object oriented programming (OOP) including nested objects
  • Support for PHP heredoc
  • Enclose strings with single- or double quotes, linefeed, carriage return or tabs
  • PHP server variables
  • PHP statement templates (if, else, then, while…)
  • Powerful PHP Code Beautifier with many configurations and profile support
  • phpDocumentor wizard
  • Add phpDocumentor documentation to functions and classes with one click!
  • phpDocumentor tags
  • Comment or uncomment with one click!
  • Jump to any declaration with filtering by classes, interfaces, functions, variables or constants

Debug (PHP):

  • Debug with Xdebug
  • Breakpoints
  • Step by step debugging
  • Step into
  • Step over
  • Run to cursor
  • Run until return
  • Call stack
  • Watches
  • Context variables
  • Evaluate
  • Profiling
  • Multiple sessions
  • Evaluation tip
  • Catch errors


Monday, March 21, 2016

Configure PayPal with Instant Payment Notification

IPN1.PNG
1- Login to your PayPal Business Account
2- Go My Account -> Profile -> My selling tools
3- Click update on Website preferences
4- Choose off for Auto Return and remove the url inside
IPN2.PNG
5- Choose off for Payment Data Transfer
IPN3.PNG
6- Click save button
IPN4.PNG
7- Go to Instant Payment Notification Preferences
8- Enable IPN message -> Pass your notification URL
IPN5.PNG

9- Save


More detail about IPN
4- https://www.paypal.com/kh/cgi-bin/webscr?cmd=p/acc/ipn-subscriptions-outside