Categories
Uncategorized

How to check ping status in CMD or BAT

It is often necessary to write a batch file that calls to a certain server, for example, when copying files. In this case script is run automatically in the background at a specified interval of time. What if in one of the starts the server will not be available (dropped off network, unreliable channel, etc.)? Then the script will be unsuccessful to contact the inaccessible server, trying to get something from him. The solution to this problem can be considered as a preliminary check on the availability of the server by using the well known program ping. But the ping does not return error status, and the program can not know whether you have connected successfully to the server or not. Here is the code to workaround this shortcoming.

Categories
Uncategorized

Check the number for integer in JavaScript

If you want to check the number to be integer, you can use this function:

isInt = function(field) {
  if (+field != field || field.indexOf(".") != -1) {
    return false;
  } else {
    return true;
  }
}
Categories
Uncategorized

Print and Echo differences in PHP

Very often arises the question, what is the difference between print and echo in PHP? Understanding the difference can help you to use the most applicable construction in each case.