If server has default config set not to show the errors use this at the begining of your php file:
error_reporting(E_ALL);
ini_set(‘display_errors’, ’1′);
If server has default config set not to show the errors use this at the begining of your php file:
error_reporting(E_ALL);
ini_set(‘display_errors’, ’1′);
1. If a method can be static, declare it static. Speed improvement is by a factor of 4.
2. Avoid magic like __get, __set, __autoload
3. require_once() is expensive
4. Use full paths in includes and requires, less time spent on resolving the OS paths.
5. If you need to find out the time when the script started executing, $_SERVER[’REQUEST_TIME’] is preferred to time()
6. See if you can use strncasecmp, strpbrk and stripos instead of regex Read the rest of this entry
The following are the steps I took to get php5+gd+mysql support (in parallel with the default install of php) working with my Plesk hosted sites on FC2. Hopeful it might help someone else.
mkdir /usr/local/php5libpng
cd /usr/local/php5libpng
yum install zlib-devel
wget http://kent.dl.sourceforge.net/sourc…-config.tar.gz Read the rest of this entry
gunzip libpng-1.2.8-config.tar.gz
tar -xvf libpng-1.2.8-config.tar
I highly recommend you enable safe_mode on production servers, especially in shared environments. This will stop exec functions and others that can easily prevent a security breach.
Disable Dangerous PHP Functions
PHP has a lot of potential to mess up your server and hack user accounts and even get root. I’ve seen many times where users use an insecure PHP script as an entry point to a server to start unleashing dangerous commands and taking control.
Search the php.ini file for: Read the rest of this entry
disable_functions =
The ternary operator is a shortcut comparison operator that replaces an if-else statement in a PHP script. If you use a lot of comparison statements in your scripts, this can greatly reduce the number of lines of code. The ternary operator is really very simple to use, but it does tend to confuse newbie PHP programmers.
The ternary operator is only used for assignment of values to variables and to reduce the lines of code and compact PHP statements. Although it is a little more difficult to read, once you understand how it operates, it is simple to use and understand.
Read the rest of this entry