Cookies – not the one you dunk in milk

September 10th, 2014

If you have been browsing the web foir quite sometime, then you might have come across cookies which allows your browser to remember passwords and other information that may have anything to do with your actions on a particular website. These can be preferences that would allow the browser or webpage on the browser to determine your habits online allowing it to perform the requested operations faster and easier. A cookie is called a client-based information for it is stored on the client computer (yours when you browse the web) and is taken or stored intact along with all the information it contains for a specified amount of time or till you delete your browsing history and cookies. If you have come across tracking cookies, these are information that defines you to a particular web page which is called upon on your next visit. When creating cookies with your page, there are specific parameters (cookies by the way are created using user-made code in PHP) that must be remembered so as not to fill up the hard disks of your client computers as they visit your website page again and again. The function setcookie is used with the following syntax:

setcookie(var1, var2, time)

The var 1 stands for the name of the cookie you are creating, with the var 2 containing the value of the said cookie and the last parameter is the time which specifies the amount of time it takes for the function to kill (terminate/delete) the cookie. A more defined and elaborate explanation of the function can be found on this <a href=”http://www.php.net/manual/en/function.setcookie.php”>page</aq>.

Array_diff_uassoc Function

September 3rd, 2014

Next in line is array_diff_uassoc() function which compares two or more arrays while checking for differences before comparing the keys with a user-defined location. It then returns an array withthe keys and values from the first array(to which all the values were comapred against) it the function allows it. Syntax is as follows : array_diff_uassoc(array1,array2,array3….,function). with a sample below of how it is used.

function userdefined($v1,$v2)
{
if ($v1 === $v2)
{
return 0;
}
if ($v1 > $v2)
{
return 1;
}
else
{
return -1;
}
}
$a1=array(0=>”Dog”,1=>”Cat”,2=>”Horse”)
$a2=array(3=>”Dog”,1=>”Cat”,5=>”Horse”)
print_r(array_diff_uassoc($a1,$a2,”userdefined”));
?>

which results in the following output : Array( [0] => Dog [2] => Horse). For an example of the same function with two or more assigned arrays to the function:

function userdefined($v1,$v2)
{
if ($v1 === $v2)
{
return 0;
}
if ($v1 > $v2)
{
return 1;
}
else
{
return -1;
}
}
$a1=array(0=>”Dog”,1=>”Cat”,2=>”Horse”)
$a2=array(3=>”Dog”,1=>”Cat”,5=>”Horse”)
$a3=array(6=>”Onyx”,0=>”Dog”,5=>”Horse”)
print_r(array_diff_uassoc($a1,$a2,$a3,”userdefined”));
?>

Which in turn, gives you : Array ([2] => Horse )

So we see the different array_diff function variants and the diffeerent ways they are used to compare the values of one or more arrays with one another.

Online computer programming courses

August 27th, 2014

There are varying reasons behind one’s choice of becoming a computer programmer. There are those that simply have the skills, others are just very eager to learn more about computers, while of course, those that want to earn big. These varying reasons led to the continuous demand for computer programmers which eventually made such career to be easily attained through convenient yet beneficial online computer programming courses. Why are these courses beneficial? Just like any traditional computer programming courses, these as well cater to essential learning and exposures that definitely develop one’s skills and experience. These courses as well pave way for effective yet convenient learning mainly because these are known for being flexible. Students are given the freedom to choose their own schedule and still cater to other priorities such as other work, studies, family, and even leisure. These courses are options that people with interest in computers should definitely consider.

Arrays

August 20th, 2014

Arrays are what tables are to C-based programming languages and what databases are for SQL-based languages. Arrays or tables as they are sometimes called can be used to store the contents of several variables and to create one, you use the following syntax:

Array(key=>value)

The array in the syntax refers to the name of the array being created, the key is the index which is set automatically to a numeric character or string if none is specified. Value is the assigned value or content of the said array which can be seen easily in the following array creation example:

$b=array('z'=>‘Comedy”,’y'=>”Horror”,’x;’=>”Action”);
print_r($b);
?>

This piece of code would produce an output of :

Array ([0] => Comedy [1] => Horror [2] => Action)

More on array functions in the next posts.

Using Built-in Functions

June 30th, 2013

espresso PHPYou may be excited about your growing PHP prowess, but why make life more difficult than you have to?

One of the great things about PHP, and other programming languages for that matter, is that it comes with built-in functions. While you can always hard code your way through any problem, using built-in functions will shorten your code and cut the time and effort you need to finish any project significantly. This will give you more time on your hands to engage in other productive activities like checking your FOREX investments or going on a date with your partner.

One easy example where in built-in functions will help you shorten your work is the use of array chunk functions. While you may always convert a string into an array by iterating on string characters, you don’t have to do that at all since there are PHP functions designed to specifically do that for you.

So use built-in functions if you want to be a more efficient programmer.

Photo Credit

Extracting More from PHP with the QB Extenstion

May 30th, 2013

QB logoOne of the weaknesses of PHP is that it isn’t doesn’t perform to well when used to develop computationally intensive tasks. Sure, its great for even the most complex of web applications, but is often skipped over in preference of another language for when it comes to computing.

An extension for PHP called QB, remedies this problem “by translating Zend opcodes and executing them through a statically typed virtual machine” resulting in a significant gain in performance even for complex tasks such as pixel-level image manipulation.

If you are new to PHP though, barely understanding the array chunk function, dabbling with PHP+QB is not advised and would be akin to handing your platinum credit card over to a teenager for use; perfect recipe for a disaster. Advanced programmers could benefit from this though it is recommended that you have a pretty fast system once you start compiling since compiling QB from source code is quite memory extensive, requiring at least 2 gigabytes of memory.

Photo Credit

Being a programmer

May 21st, 2013

The want of becoming of a programmer all starts with taking introductory classes that cater to the study of basics in programming. These classes should help one develop two important aspects namely logic and discrete Mathematics which are essential in any programming career. The next thing to be done is understand other aspects of programming which includes its involved database, system, and languages. This should be done mainly because through understanding those things, one can identify which type of programming is fit for him or her which is actually the next step. There are varying types of programmers and these include desktop application programmer which focuses on operating systems, system programmer which deals with drivers and software, and web programmer. Lastly, when one is assured of what to pursue, one can then focus on learning the details of that chosen specialization which includes technologies and programming languages to be used.

Learning Computer programming

May 21st, 2013

Learning computer programming requires two important aspects namely time and effort. It is a must that before even trying to learn the basic codes, one has that willingness to sacrifice time and other priorities. This is the case because computer programming is never easy to learn. Every code has varying use, result, and applications which should be understood in detail by any programmer. Effort and initiative, on the other hand, are the secrets to one being successful in this field. These are needed since learning and mastering computer programming is a long procedure that involves the need of much practice. Practicing is not required from for instance, a professor or a school. This will only be possible if one has the initiative. It is important to known that, learning computer programming is possible to anyone even those that have the least knowledge on computers. One should simply have that willingness to sacrifice time, effort, and initiative. Success will definitely follow.

Downsides of Computer programming

May 21st, 2013

Computer programming is known for its immeasurable contribution to the online community and to the world of technologies. Users are highly dependent to such programming because it caters to several usages that appear to be of great benefit. Taking all those benefits and advantages aside, it is as well important for every user to be aware of the disadvantages that go with computer programming. First downside focuses on the increasing forms of viruses. As we all know, programmers are responsible for varying websites, systems, and programs. These are all products of their effort and definitely took much time to finish but due to prevalent viruses, these works at one instant can be infected and destroyed. Another is that computer programming must always be perfect. This pertains to the need of having completely correct codes and executing the procedure perfectly. This is important because a simple mistake or one missing code can lead to system errors and even breakdown.

PHP Version Updates

April 20th, 2013

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