Copyright © if not true then false. All Rights Reserved. Snowblind by Themes by bavotasan.com. Powered by WordPress.

Posts Tagged ‘ PHP ’
Adobe Apache Applications Bash CentOS Coding Command line CSS Database date Fedora Firefox Gnome Google Guide Howto HTML JavaScript KDE Links Linux MySQL News Perl PHP PostgreSQL PostgreSQL Partitioning Programming Programs psql Red Hat RHEL Security SQL Styles Terminal time Tips Tricks Tweets Twitter UNIX Windows XFCE Yum

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"
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.
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"
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
In many cases, it is really useful to know the exact time for how long a PHP script is running or how long will take PHP web page load. On the other hand it is also useful to know that how long a particular script operation or part of page load will take.
Following PHP Timing class is very simple to use, only create class and start timing and stop timing. Elapsed time function can be used also (elapsed time is calculated from script start time). Statistics can be displayed in print-functions and the same information without any formatting can also get with get-functions.
