Script Perfect

         Random snips of code and bugs

PHP and APC – Tutorial

Posted by Tim On September - 12 - 2009

APC is most widely known for allowing the end user to be able to track the progress of file transfers. APC, which stands for “Alternative PHP Cache” does much more than that. Complex and large scale websites can benefit from it’s ability to cache data and as well as its optimization of PHP code.

If you are looking for a tutorial on using APC for tracking file upload progress then visit my tutorial for File Upload Progress

APC does not have a large host of commands, this does not ease the complexity. We will take a look at a few simple functions and explain their use, in addition I will try to explain the practical reasons to use them. There are a few warnings to adhere to when trying utilize alternative PHP cache, these will also be discussed.

Read the rest of this entry »

Ajax – A Squeeky Clean Website

Posted by Tim On September - 8 - 2009

Ajax, not the cleaner, the asynchronous JavaScript and XML, it is like viagra for your website. Pop in a little Ajax and your website is performing better and making your “visitors” happy. As with viagra you need to read the warning labels associated with Ajax.

Warning:

Ajax should be used in moderation. If your server maintains a full load for more than 4 hours as a result of using Ajax, you should consult a programmer immediately. Websites hosted on shared servers or those intending to move to a shared server should not use Ajax as this may cause complications during deployment.

Seriously though, over use of Ajax can cause a lot of load on your server if you are processing too many requests at the same time, often the requests that tax the server the most include database queries. Don’t get me wrong, I love Ajax and I think every site could put it to good use. This is why I am going to show you a few simple methods to implement it on your site to make your visitors time more enjoyable.

Read the rest of this entry »

PHP Regex Crash Course

Posted by Tim On September - 6 - 2009

Regex, or regular expression is used to match characters in a string, the problem with using it is knowing how to use it. As with many things it takes practice and memorization to fully understand and commit it to memory. Regex is a powerful tool and can shorten many tasks such as validating email addresses, redirecting users with mod_rewrite, and searching for illegal characters in a submitted field.

PHP uses two very powerful statements to utilize regex, the first is called preg_match which takes a string and tries to match the pattern you provide it. The second statement is preg_replace which will do the same as preg_match with the exception that it will replace the pattern it finds with some other string you provide. I say only two here and some of you may be thinking “liar!” so I will mention a few others, there is ereg and eregi, they do basically the same things that the preg functions do, just not as fast or powerful. These are the only ones I will be covering, there are several preg functions besides these that you can research at your own pace.

Read the rest of this entry »

About Me

I am an independent web developer and webmaster of many sites. The main goal of Script Perfect is to provide answers to some of the hard to find questions when it comes to website design and coding.

Twitter