≡ Menu

PHP Tutorials & HowTos

PHP is an open-source server-side scripting language and one of the most popular in web development. This section includes PHP programming related syntax, questions and answers ( rss feed ).

One of my php script called setoptions.php is hosted on my new vps server. However, it is not working so I setup php error log as described here and, and I see the following warning repeated in my log file:

PHP Warning: fread(): Length parameter must be greater than 0 in /var/www/html/scripts/setoptions.php on line 311

The line no # 311 is as follows in my php script:
$fname = 'myappconfig.php';
$content = fread($fhandle,filesize($fname));

How do I fix this problem under Unix/Apache/php5 server?
[click to continue…]

CentOS / RHEL: Install and Configure phpMyAdmin Administration Of MySQL Database Server

How do I install phpMyAdmin to handle the administration of MySQL database server over the World Wide Web under Fedora / Scientific / CentOS / RHEL / Red Hat Enterprise Linux 6.x server systems? How do I install and securely configure phpMyAdmin on a CentOS 6.x / RHEL 6.x server?
[click to continue…]

PHP: Require_once(): Unable To Allocate Memory For Pool Error and Solution

I'm running PHP version 5.3.3 on CentOS / RHEL 6.x with APC php-pecl-apc-3.1.9. However, I'm getting the following warnings in my php server log file:

[01-Jul-2012 10:50:49] PHP Warning: require_once(): Unable to allocate memory for pool. in /var/www/html/includes/admin.php on line 57
[18-Jul-2012 17:00:08] PHP Warning: include_once(): Unable to allocate memory for pool. in //var/www/html/includes/xmlrpc.php on line 55
[18-Jul-2012 17:00:40] PHP Warning: require(): Unable to allocate memory for pool. in /var/www/html/includes/geshi.php on line 2307

How do I fix these php warnings?
[click to continue…]

PHP: GeSHi Syntax Highlighter Enable / Disable Line Numbers

I'm using GeSHi under php to highlight a source code. How do I turn on or off line numbers using GeSHi?
[click to continue…]

Find Out PHP Version installed On Unix / Linux Server

How do I find out php version under Linux operating systems? How do I find out php version under Unix like systems? How to find out what version of PHP is installed on my server?
[click to continue…]

PHP: <? ?> Tags Not Working in PHP 5.3.x under UNIX / Linux

I've recently installed php 5.3.5 in my UNIX box and my old working php code not working. It displays code in pages which is in <? ... my code ... ?> php tags. How do I fix this problem?
[click to continue…]

Linux: phpinfo() system’s timezone error date.timezone

I'm getting the following errors in my log file whenever I use phpinfo() function:

[10-Jan-2011 18:39:08] PHP Warning: phpinfo(): It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'America/Chicago' for 'CST/-6.0/no DST' instead in /home/servers/http/dev/testpc.php on line 2

How do I fix this problem under UNIX / Linux php running Apache or lighttpd web server?
[click to continue…]

HowTo: PHP Compare Two Text Strings

How can I compare two strings using php? How do I use php to compare two strings?
[click to continue…]

Mediawiki Fix Internal Server Host Names / Redirection In shared Hosting or Proxy Setup

Our customer support wiki runs on an internal host (ip:, hostname a-node100.:300) and it is behind the nginx reverse proxy server. However, our Apache server end up displaying internal server name http://a-node100.:300/, which results into an unexpected redirection and timeouts as http://a-node100.:300/ is not accessible over the Internet. How do I force nginx or apache to use the base URL of our server (http://support.example.com/wiki/)?

[click to continue…]

WordPress Rename Image URL For a CDN Usage

Recently, we moved all our static assets to a CDN (Content Delivery Network) as described here. However, we have over 8000+ old blog posts and we need to point static images url to our CDN account hosted at http://MyACCOUNT.cloudfront.net/images/ folder. How do I rename all image urls stored in wordpress posts? How do I offload static images to a CDN urls under WordPress?
[click to continue…]