Category: PHP

Software Development 0

Setting permanent 301 redirect via .htaccess

Redirect individual files To redirect individual files, like example.com/oldfile.htm to newfile.htm you can use a 301 redirect like this

To redirect one specific file to another domain such as example.com/oldfile.htm to example.net/newfile.htm, you need to add the full URL with the domain name.

Redirect an old domain to a new domain If you have a new domain and want to preserve the traffic and SEO of the old domain, you can write a domain wide redirect. This will tell the browser and the spiders “Hey, I moved to a new address, please update my address on your address...

PHP with Smarty Template Engine 0

Autoloading Class Problem With Smarty

If you are using Smarty Template engine with your PHP code and you happen to use an autoloader, then you may have encountered an autoloading class problem with Smarty stating that the file “Smarty_Internal_TemplateBase” can’t be found and your script produces a FATAL error. Smarty is using it’s own autoloader using the spl_autoload_register method and our autoloader is messing it up.

PHP Programming Start to End 0

PHP Autoloading Class

Many developers writing object-oriented applications create one PHP source file per class definition. One of the biggest annoyances is having to write a long list of needed includes at the beginning of each script (one for each class).

In PHP 5, this is no longer necessary. The spl_autoload_register() function registers any number of autloaders, enabling for classes and interfaces to be automatically loaded if they are currently not defined. By registering autoloaders, PHP is given a last chance to load the class or interface before it fails with an error.