Subscribe to RSS Feed

Posts Tagged ‘ Programming ’

PHP MongoDB (Mongo Database) Driver Installation on Linux, UNIX, BSD and Mac OS X

MongoDB PHP driver is very simple install on Linux, UNIX, BSD and Mac OS X. You need just PEAR (PHP Extension and Application Repository) with PECL repository. Normally PHP development (dev) package and PHP Pear package installation from package management system is enough to get PEAR working. Also go-pear.php script can be used.

» Continue Reading "Install PHP MongoDB (mongo) Driver on Linux, Mac OS X, Windows, UNIX, BSD"
2 Comments

PHP has large number of predefined constants. This HOWTO will present the seven most important, most practical and most useful PHP Magic Constants.

  • __FILE__ – The full path and filename of the file.
  • __DIR__ – The directory of the file.
  • __FUNCTION__ – The function name.
  • __CLASS__ – The class name.
  • __METHOD__ – The class method name.
  • __LINE__ – The current line number of the file.
  • __NAMESPACE__ – The name of the current namespace

This is example PHP script with comments, which demonstrate howto use all previously mentioned PHP Magic Constants.

» Continue Reading "Howto Use PHP Magic Constants: __FILE__, __DIR__, __FUNCTION__, __CLASS__, __METHOD__, __LINE__, __NAMESPACE__"

Please leave a comment

By default, Fedora, Centos and Redhat Linux operating system does not have the Sun’s Java. These use the OpenJDK Java, which is a very good choice for normal use and it works with almost all the Java programs normally. In some cases, however, Sun’s Java installation is necessary, for example, if a particular program does not work without Sun’s Java or some program have to compile with Sun’s Java.

Howto Install Sun Java (JDK, JRE) on Fedora, CentOS, Red Hat

» Continue Reading "Howto Install Sun Java (JDK, JRE) on Fedora, CentOS, Red Hat"

2 Comments

I was using simple function to calculate difference between two dates and timestamps until I noticed, it’s not working correctly in long intervals. It’s very easy to calculate difference between two timestamps in seconds, but it’s much more complicated print difference in human readable format. The Internet can be found in a wide range of ways to do this thing, but as a rule they use a fixed amount of seconds for the year and the month. So if we calculate year with using 365 or 365.25 days and month using 30 or 31 then the difference is not accurate, because of leap years, DST (Daylight Saving Time) and so on.

Because of this problem, I decided to make a function (at least in the short testing) to return the right kind of differences between the UNIX timestamps and dates in human readable format. This function uses PHP strtotime function to calculate real differences and can handle leap years and DST. This function can also return Twitter like about texts with precision parameter.

» Continue Reading "PHP: Calculate Real Differences Between Two Dates or Timestamps"

Please leave a comment

PHP Command Line Interface (CLI) has not built-in coloring for script output, like example Perl language has (perldoc.perl.org/Term/ANSIColor.html). So I decided to make own class for coloring PHP CLI output. This class works only Bash shells. This class is easy to use. Just create new instance of class and call getColoredString function with string and foreground color and/or background color.

PHP Class for Coloring PHP Command Line (CLI) Scripts Output

» Continue Reading "PHP Class for Coloring PHP Command Line (CLI) Scripts Output – PHP Output Colorizing Using Bash Shell Colors"

1 Comment

Recent Comments