PHP: APC Configuration and Usage Tips and Tricks

PHP APC (Alternative PHP Cache / Opcode Cache) is framework that optimizes PHP intermediate code and caches data and compiled code from the PHP bytecode compiler in shared memory. APC Opcode Cache is quickly becoming the de-facto standard PHP caching mechanism. (adsbygoogle = window.adsbygoogle || []).push({});PHP APC installation is very easy, example with Fedora / CentOS / Red Hat (RHEL) you can check following guides to see howto install it:
Read more →

Install phpMyAdmin 4.3.10 on Fedora 21/20, CentOS/RHEL 6.6/5.11

This is guide, howto install phpMyAdmin 4.3.10 with Nginx or Apache on Fedora 21/20/19, CentOS 7/6.6/5.11 and Red Hat (RHEL) 7/6.6/5.11 servers. phpMyAdmin needs web server with PHP and MySQL database. This guide uses Apache web server with PHP 5.6 or Nginx web server with PHP 5.6 (PHP-FPM) and MySQL 5.6 database server or MariaDB 10/5.5 database server. You can also use your already installed versions of web server, PHP and MySQL.
Read more →

PHP / PDO / SQLite3 Example

This is a PHP, PDO and SQLite3 example, which demonstrates the SQLite3 databse usage with PHP-PDO. The PHP / PDO / SQLite3 example code demonstrates following things, and their use: Create / Connect SQLite3 databases Use SQLite3 file and memory databases Create tables in SQLite3 database Use SQLite3 db different datetime formats Insert data to SQLite3 database PDO / SQLite3 prepared statements Bind parameters to statement variables Bind values to statement variables Quote a string for use in a query Update data in SQLite3 database Select / Query from SQLite3 database and print query output Drop SQLite3 table Close SQLite3 connections PHP / PDO / SQLite3 Example Code <?
Read more →

LEMP on Fedora 28/27, CentOS/Red Hat (RHEL) 7.5/6.10

LEMP (Linux, Nginx, MySQL, PHP) server is extremely powerful setup behind any website or web based service. This guide is collection of Fedora/CentOS/Red Hat (RHEL), Nginx, MariaDB/MySQL and PHP (PHP-FPM) install guides. This guide (more specifically this guide parts) try to explain in more detail LEMP (Linux, Nginx, MariaDB/MySQL, PHP (PHP-FPM)) server environment installation. This howto can be used to pre-installed Linux, and instructions can be used for various Fedora and Red Hat based Linux distros with YUM.
Read more →

PHP Memory Usage Information Class

Sometimes it’s nice to know or even very important to know, how much your PHP script is using memory. This is a simple example of a class, which can be used to collect the PHP script memory usage information and to print all information. It’s easy to reformat output, if you want to use it example on web page or command line script. Or even do another function for web pages and another for command line scripts.
Read more →

Install Nginx/PHP-FPM on Fedora 29/28, CentOS/RHEL 7.5/6.10

This is guide howto install Nginx with PHP 7.2.12 and PHP-FPM on Fedora 29/28/27, CentOS 7.5/6.10 and Red Hat (RHEL) 7.5/6.10. PHP-FPM is easier to use and configure than FastCGI and some tests says that PHP-FPM is even much more efficient than FastCGI. Nginx (engine x) is a robust, small and high performance http server, reverse proxy server and also mail proxy server. PHP-FPM (FastCGI Process Manager) is an alternative PHP FastCGI implementation with some additional features useful for sites of any size, especially busier sites.
Read more →

Zend Framework on Fedora 18/17, CentOS/Red Hat (RHEL) 6.4/5.9

This is quick guide, howto install Zend Framework (ZF) 1.12.3 on Fedora 18/17/16/15, CentOS 6.4/6.3/6.2/6.1/6/5.9 and Red Hat (RHEL) 6.4/6.3/6.2/6.1/6/5.9. This guide also works with older Fedora releases, like Fedora 13/12/11 and also with older CentOS/Red Hat RHEL 5 releases. I use Remi repository here because it’s updated more frequently than example Fedora’s own repositories. What is Zend Framework? Zend Framework is a simple, straightforward, open-source software framework for PHP 5 designed to eliminate the tedious details of coding and let you focus on the big picture.
Read more →

PHP: Remove Last Character from String – substr / substr_replace / rtrim

This is a very common PHP question, how to remove last character from string in PHP? So here are three ways how to delete last character from string in PHP. Method 1 – PHP: Remove Last Character from String using substr and mb_substr substr and mb_substr commands usage substr($string, 0, -1); mb_substr($string, 0, -1); substr and mb_substr example: $string = "This is test string.."; echo $string . "\n"; // substr function echo "substr: " .
Read more →

Install WordPress 4.1.1 on Fedora 21/20, CentOS/RHEL 7/6.6/5.11

This is guide, howto install WordPress 4.1.1 with Nginx or Apache on Fedora 21/20/19, CentOS 7/6.6/5.11 and Red Hat (RHEL) 7/6.6/5.11 servers. WordPress needs web server with PHP and MariaDB or MySQL database. This guide uses Apache web server with PHP 5.6 or Nginx web server with PHP 5.6 (PHP-FPM) and MariaDB 10/5.5 database server or Mysql 5.6 database server. If you want to install WordPress with Apache then use a – [Apache] sections and if you want install WordPress with Nginx then use b – [Nginx] sections.
Read more →

PHP 1st, 2nd, 3rd, 4th, 5th, 6th – PHP Add Ordinal Number Suffix

This is simple function to add English ordinal number suffix after normal number. Function takes number as a parameter and returns number with suffix, like: 1st, 2nd, 3rd, 4th, 5th, 6th… This is example table of ordinal numbers 1 to 100 1st 2nd 3rd 4th 5th 6th 7th 8th 9th 10th 11th 12th 13th 14th 15th 16th 17th 18th 19th 20th 21st 22nd 23rd 24th 25th 26th 27th 28th 29th 30th 31st 32nd 33rd 34th 35th 36th 37th 38th 39th 40th 41st 42nd 43rd 44th 45th 46th 47th 48th 49th 50th 51st 52nd 53rd 54th 55th 56th 57th 58th 59th 60th 61st 62nd 63rd 64th 65th 66th 67th 68th 69th 70th 71st 72nd 73rd 74th 75th 76th 77th 78th 79th 80th 81st 82nd 83rd 84th 85th 86th 87th 88th 89th 90th 91st 92nd 93rd 94th 95th 96th 97th 98th 99th 100th Add Ordinal Suffix PHP Function <?
Read more →

LAMP on Fedora 28/27, CentOS/Red Hat (RHEL) 7.5/6.10

LAMP (Linux, Apache, MariaDB/MySQL, PHP) server is very powerful server setup behind any website or web based service. This guide is collection of Fedora/CentOS/Red Hat (RHEL), Apache, MariaDB/MySQL and PHP install guides. Today the Internet is full of instructions, which promises a LAMP server installation with a “One-Liner”, and so forth. In fact, these “One-Liner” instructions assume that, Linux is already installed and installs just AMP (Apache, MariaDB/MySQL, PHP) pakages, without any configuration.
Read more →

Install Apache/PHP 7.2.12 on Fedora 29/28, CentOS/RHEL 7.5/6.10

This guide shows howto install Apache HTTP Server (httpd) with PHP 7.2.12 and following modules on Fedora 29/28/27, CentOS 7.5/6.10 and Red Hat (RHEL) 7.5/6.10 systems. OPcache (php-opcache) – The Zend OPcache provides faster PHP execution through opcode caching and optimization. APCu (php-pecl-apcu) – APCu userland caching CLI (php-cli) – Command-line interface for PHP PEAR (php-pear) – PHP Extension and Application Repository framework PDO (php-pdo) – A database access abstraction module for PHP applications MySQL (php-mysqlnd) – A module for PHP applications that use MySQL databases PostgreSQL (php-pgsql) – A PostgreSQL database module for PHP MongoDB (php-pecl-mongodb) – PHP MongoDB database driver Redis (php-pecl-redis) – Extension for communicating with the Redis key-value store Memcache (php-pecl-memcache) – Extension to work with the Memcached caching daemon Memcached (php-pecl-memcached) – Extension to work with the Memcached caching daemon GD (php-gd) – A module for PHP applications for using the gd graphics library XML (php-xml) – A module for PHP applications which use XML MBString (php-mbstring) – A module for PHP applications which need multi-byte string handling MCrypt (php-mcrypt) – Standard PHP module provides mcrypt library support 1.
Read more →

Install Eclipse Mars 4.5 on Fedora 24/23, CentOS/RHEL 7.2/6.8/5.11

This is guide, howto install latest Eclipse Mars.2 4.5.2 on Fedora, CentOS and Red Hat (RHEL). This guide should work with Fedora 24/23/22/21/20/19/18/17/16/15/14/13/12, CentOS 7.2/6.8/5.11 and Red Hat (RHEL) 7.2/6.8/5.11 and even with earlier versions. Latest working version on CentOS/RHEL 5.11 is Eclipse Luna 4.4.2. Eclipse is a multi-language software development environment comprising an integrated development environment (IDE) and an extensible plug-in system. It is written primarily in Java and can be used to develop applications in Java and, by means of various plug-ins, other languages including C, C++, COBOL, Python, Perl, PHP, Scala and Ruby (including Ruby on Rails framework).
Read more →

PHP mb_ucfirst Make a String’s First Character Uppercase-Multibyte (UTF-8) Function

PHP’s ucfirst function is very usefull when you want to change words first letters to uppercase and other letters to lowercase. Currently on PHP does not have a multibyte (UTF-8) version of ucfirst function. So I decided write my own multibyte mb_ucfirst function. Perhaps the multibyte version of ucfirst function is added later on PHP, so that’s why is better add this function only if it does not already exist.
Read more →

Install PHP MongoDB (mongo) Driver on Linux, Mac OS X, Windows, UNIX, BSD

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. Check that the PEAR and PECL are working with the following commands:
Read more →

PHP DIR, FILE, FUNCTION, CLASS, METHOD, LINE, NAMESPACE

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.
Read more →

PHP: Calculate Real Differences Between Two Dates or Timestamps

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.
Read more →

PHP CLI Colors – PHP Class Command Line Colors (bash)

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 adding colors on 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 <?
Read more →

PHP - Measure Scripts Execution Time and Page Generation Time

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.
Read more →

PHP stdClass to Array and Array to stdClass – stdClass Object

I think every PHP coders have come accross Arrays and stdClass Objects (belongs to PHP Predefined Classes). Sometimes it’s very useful convert Objects to Arrays and Arrays to Objects. This is easy if arrays and objects are one-dimensional, but might be little tricky if using multidimensional arrays and objects. This post defines two ultra simple recursive function to convert multidimensional Objects to Arrays and multidimensional Arrays to Objects. Function to Convert stdClass Objects to Multidimensional Arrays <?
Read more →
Subscribe and follow: