Archive for the ‘PHP’ Category

How to fix ereg and ereg_replace is deprecated errors in PHP 5.3

 
If you upgraded to PHP 5.3 Version, chances are high you’re going to run into a few warnings or deprecated function error messages.
 
ereg is deprecated
 
An example is the ereg family of functions, which are gone for good, as they were slower and felt less familiar than the alternative Perl-compatible preg family.


 
To migrate ereg() to preg_match()
 
Before
 
ereg('\.([^\.]*$)', $this->file_src_name, $extension);
 
After
 
preg_match('/\.([^\.]*$)/', $this->file_src_name, $extension);
 
Notice that we should wrapped the pattern (\.([^\.]*$)) around / /, which are RegExp delimiters. If you find yourself escaping / too much (for an URL for example), you might want to use the # delimiter instead.


Read more »

How To Optimize Your Site With GZIP Compression

 
Step 1
 
First you need to access your .htaccess file through cPanel by clicking on the File Manager. When the popup box appears, click on the Web Root option and make sure that the “Show hidden files” option is checked.
 

Add Leverage Browser Caching 1


 
Step 2
 
Open up your .htaccess file and paste the following lines.
 

Read more »

How to Install NetBeans on Ubuntu

To use NetBeans for Java, PHP programming, you need to first install JDK. Read "How to install JDK on Ubuntu".

Step 1 : Download netbeans
 
Download NetBeans from http://netbeans.org/downloads/. Choose platform "Linux (x86/x64)" ⇒ "Java SE". You shall receive a sh file (e.g., "netbeans-7.x-ml-javase-linux.sh") in "~/Downloads".
Set the downloaded sh file to executable and run the sh file.


Step 2 : Install netbeans
 
Open a Terminal and type the following commands.
 
cd ~/Downloads
chmod a+x netbeans-7.x-ml-javase-linux.sh   // Set to executable for all (a+x)
./netbeans-7.x-ml-javase-linux.sh                   // Run
 
Follow the instructions to install NetBeans.


Read more »