How to Deliver Content Fast

February 26th, 2015

It used to be the norm of having all the information collated into one single server for ease of security and maintenance. With the internet and social media’s ever increasing reach, content delivery becomes a real issue and with the advent of cloud computing, loading times is all that matters.

Geographical location plays an important factor when it comes to page load times and content delivery and dispersing your content over a wide swath of geographically strategic locations allows for fast page loads. It also prevents overloading of a single server that can choke and seize up in the event of huge demand.

More Programming Basics

February 19th, 2015

As with all programming languages PHP has different variable types such as numeric, character, string and Boolean types. Boolean variables in PHP always return either true or false, integers are whole numbers, floating points are decimal or scientifically notated and strings are a chain of characters. Sounds familiar, well they are and they are mostly standard across the various programming languages. For a more in-depth discussion on the different data types of PHP go visit the manual page.
We next discuss operators such as the assignment operator which allows you to assign values to variables allowing complex operations to be constructed into more and more functional programs.

Open Source Social Page Authentication Made Easy

February 12th, 2015

Using a little known library that has been uploaded through the community, HybridAuth contains access verification capabilities for social networking sites that are on the internet today. Developers are always on the lookout for the best and most robust ways of protecting people who do want to get into social networking sites through blogs and many others the solution being a blessing for those who want to gain access to OpenID, LinkedIn, Foursquare, Yahoo and Tumblr.
More information can be found on the SourceForge project page where tons of other nifty additions to your page can be found and used almost for free.

PHP – Single vs. Double Quotes (Part 2)

February 5th, 2015

Single quotes are used to define a set of characters and double quotes for variables, and as said the two are not inter-changeable and PHP will not check for a variable within single quotes. Below is a faster way of doing the same script with the simple substitution of the double for the single quotes.

Example:
$myword = ‘PHP is Free’;
if ($myword == ‘PHP is Free’)
{
echo ‘Learn it Easy’;}

The changes might be very minimal but for a serious scripting author, speed is of the essence and slow web pages are quite annoying.  As a web user like you and me should know, the faster a page opens, the better and the more we like it.

PHP and other Programming Languages

February 5th, 2015

The major notable difference with PHP against other languages with regards to variables is that PHP is more “intelligent”. In C for example, variables have to be explicitly defined as either numeric or alpha-numeric and can only be used to store that defined specific form of data. PHP like all other languages supports a lot of variable types such as integers, floating point numbers, arrays and strings but with one major difference, variables are recognized automatically based on their use and the context of their use. This makes your (programmer’s) life a whole lot easier. PHP variables are defined with a “$” symbol preceding the variable name. It should also begin with either an underscore or an alpha character.

Arrays : Changing cases

January 29th, 2015

This form of array declaration allows one to change the case from uppercase to lowercase and vice versa. The syntax goes as follows:

array_change_key_case(array,case)

The array part, specifies which table or array to use and is a required field which is not the case with the key which is automatically assigned a value. An example of it’s use can be seen below:

$a=array('a'=>“Mouse”,’b'=>”Rat”,’c'=>”Rodent”,’d'=>”Cat”);
print_r(array_change_key_case($a,CASE_UPPER));
?>

The output of the said commands will be:
Array ( [A] => Mouse [B] => Rat [C] => Rodent [D] => Cat)

Another example of it’s use would be:

$a=array('a'=>“Mouse”,’B'=>”Rat”,’c'=>”Rodent”,’b'=>”Cat”);
print_r(array_change_key_case($a,CASE_UPPER));
?>

That returns the following values respectively:
Array ( [A] => Mouse [B] => Rat [C] => Rodent [D] => Cat)

In the next post, we would discuss an array function that divides a large array into several chunks of separate arrays.

Array_diff Function

January 22nd, 2015

The first function, array_diff() is used for comparing several tables or arrays which gives an array with the keys and values from the first array if the value is not available in the other arrays. Syntax is as follows : array_diff(array1,array2,array3……), where array 1 is the table to which all the other arrays will be compared to. The 2nd array(array 2) is an array that is compared with the first array and so on and so forth. Below is sample code of its use and the outcome of the functions comparison :

$a1=array(0=>“Mouse”,1=>”Cat”,2=>”Dog”);
$a2=array(3=>”Dog”,4=>”Cat”,5=>”Lizard”);
print_r(array_diff($a1,$a2));
?>

Giving you the result : Array( [0] =>Mouse )

PHP Version Updates

January 15th, 2015

php programmingThe PHP development team announced 3 releases earlier this month, including the latest beta version of PHP 5.5.0. Aside fom PHP 5.5 beta 3, the other versions released this month are the PHP 5.3.24 and the PHP 5.4.14.

The PHP development team urges programmers to upgrade to the 5.4.14 version since it not only contains fixes to critical bugs, but also comes with an upgraded PCRE library. It should also be noted that while the 5.5 version is the latest version, those new to PHP programming are discouraged from using the version since it is still in beta and still contains many bugs that need to be fixed. Even experienced programmers are advised not to use the 5.5 version for projects that will go into production, unless you are ready to gamble your financial interest in your commercial project with a buggy program. If interested in trying out the beta version though it might also be wise to just wait for the next beta release of PHP 5.5.0 since it is expected to come out just a few days away on April 25.

Photo Credits

The Alarming Security Gaps

January 8th, 2015

PHP being the most used scripting language for deploying web pages is under a lot of scrutiny as well as the many projects that used it as framework. One of these is WordPress which has suffered a lot of malicious attacks in the form of code insertion and comments spamming which is intended to influence adSense ratings or ranking to promote malicious sites to boost rankings. This promotes them without the owner’s knowledge which is more the norm for blogs seldom get administered properly. Read the rest of this entry »

Secure PHP Scripts for Online Credit Card Transactions

January 1st, 2015

Online shopping sites depend heavily on credit cards for transactions to push through. While alternative like PayPal exist, a lot of online shoppers prefer the convenience of being able to use their credit cards without having to top up their PayPal accounts, much less go through the hassle of other payment options like sending in a check.

e-Commerce sites, however, need to be very careful when it comes to accepting credit card details because alarming security gaps can cause bigger legal problems since this is people’s financial information we are talking about. This is why the PHP script you use to securely accept credit card details online is very important. You can always have a custom-made PHP script developed for this particular purpose, but there are already some good commercial scripts out there like PHP Credit Card. Whatever code you do use for an e-Commerce shop though, make sure that security is the main priority.

Image via PHP Credit Card