PHP 5.6: What’s New

php

It’s been a long time coming, but we finally have a new version of PHP. With it comes a some nice, new features, improvements to existing features, as well as features that have been removed or marked as deprecated.

Let’s dive in and take a look at everything that’s offered by the latest version.

In this part, I’ll be listing backwards incompatible changes; however, most of your PHP5 code will work in PHP 5.6 without any modifications.

As per the JSON specification json_decode() will immediately eliminate all non-lowercase variants of the JSON literals like true, false and null along with this it will set json_last_error() accordingly.

If you are not sure what GMP in PHP then I would advise looking at here. In PHP 5.6, GMP resources are objects. You do not need to make any changes in your existing code unless you are checking resource using explicitly using is_resource().

All Mcrypt function which expect key and IVs will not accept keys or IVs with incorrect size, these functions includes mcrypt_encrypt(), mcrypt_decrypt(), mcrypt_cbc(), mcrypt_cfb(), mcrypt_ecb(), mcrypt_generic() and mcrypt_ofb().

Before PHP 5.6 when you declare array in class property with explicit and implicit key, array value was overwritten silently when explicit key was the same as a sequential implicit key.

01
02
03
04
05
06
07
08
09
10
11
12
13
14
15
16
17
18
19
class helloWorld {
        const ONE = 1;
        
        public $array = [
            self::ONE => 'Eclipse',
            'Sublime',
            'PHPStrome',
        ];
    }
    
    $hello = new helloWorld();
    
    print_r($hello);
    
    // Before PHP 5.6
    array('Sublime', 'PHPStrome')
    
    // PHP 5.6
    array('Eclipse', 'Sublime', 'PHPStrome')

With the release of PHP 5.6, it is possible to provide a scalar expression which includes both numeric and string literals. In previous versions of PHP, it was expected to be static value of constant, function arguments and property declaration.

01
02
03
04
05
06
07
08
09
10
11
12
13
14
15
const ONE = 1;
// Scalar Expression in constant
const TWO = ONE * 2;
class helloWorld {
    // Scalar Expression in Property   
    const THREE = TWO + 1;
    
    // Scalar Expression in Methods
    public hello f($a = ONE + self::THREE) {
        return $a;
    }
}
echo (new helloWorld)->hello()."\n";

Earlier we were using func_get_args() to get all arguments available in function call, but with PHP 5.6, this can be removed as we can easily get that facility with ... operator.

01
02
03
04
05
06
07
08
09
10
11
12
13
14
15
16
17
18
19
20
function myTools($name, ...$tools) {
    echo "Name:". $name.'<br />';
    echo "My Tool Count:". count(tools);
}
myTools('Avinash', 'Eclipse');
// Output:
// Name: Avinash
// My Tool Count: 1
myTools('Avinash', 'Eclipse', 'Sublime');
// Output:
// Name: Avinash
// My Tool Count: 2
myTools('Avinash', 'Eclipse', 'Sublime', 'PHPStrom');
// Output:
// Name: Avinash
// My Tool Count: 3<b>
</b>

We can use the same operator (...) to unpack any argument which is either an array or a set of traversable objects.

01
02
03
04
05
06
07
08
09
10
11
12
13
14
function myTools($name, $tool1, $tool2, $tool3) {
        echo "Name:". $name.'<br />';
        echo "Tool1:", $tool1.'<br />';
        echo "Tool2:", $tool2.'<br />';
        echo "Tool3:", $tool3;
    }
    
    $myTools = ['Eclipse', 'Subline', 'PHPStrom'];
    myTools('Avinash', ...$myTools);
    // Output:
    // Name: Avinash
    // Tool1: Eclipse
    // Tool1: Subline
    // Tool1: PHPStrome

** operator has been added for exponentiation, we have got support for the shorthand operator as easily.

1
2
3
4
5
6
7
8
9
echo 2 ** 3;
echo "<br/>";
$a=2;
$a **= 3;
echo $a;
// Output
// 8
// 8

Note that the order of operations comes into play using this operator. Please take a look at the following example for a clear understanding:

1
echo 2 ** 2 ** 4;

You might expect it to return 256 as grouping would be like (2 ** 2) ** 4 but that is not the case here. Real result would be 65536 as grouping would be from right to left and it will parse as 2 ** (2 ** 4).

An interactive debugger called phpdbg has been added in PHP 5.6. Please visit the official document for phpdbg.

This phpdbg debugger is implemented as SAPI module.

A new magic method added in PHP 5.6, this method allow to change properties and values of an object when the object is output using var_dump().

01
02
03
04
05
06
07
08
09
10
11
12
13
14
15
16
17
18
19
class demoDebugInfo() {
    private $val;
    
    public function __construct($val) {
        $this->val = $val;
    }
    
    public function __debuginfo() {
        return [
            'iamchanged' => $this->val + 3;
        ];
    }
}
$debugInfo = new demoDebugInfo(50);
// We will get altered array which is returned by __debuginfo megic method.
var_dump($debugInfo);<b>
</b>

Default character set for htmlentities(), html_entity_decode() and htmlspecialchars() functions can be set using  default_charset()

It is possible to upload file larger than 2GB.

php://input can be used as many times you want to read data. This feature has great reduction in memory compare to reading POST data.

use operator has been offered to support extending of constants and functions, this can be performed by using the const and the use functions, respectively. Earlier this operator was limited to class only.

Immediately it will generate E_DEPRECATED error when you attempt to access non static method statically or static method using object context.

01
02
03
04
05
06
07
08
09
10
11
12
13
14
15
16
class helloWorld() {
    public static hiWorld () {
    
    }
}
$hello = new helloWorld();
$hello->hiWorld();
// Before PHP 5.6
E_STRICT error
// From PHP 5.6
E_DEPRECATED error<b>
</b>

$HTTP_RAW_POST_DATA is deprecated now, we should be using php://input instead.

With the launch of default_charset() configuration related option is deprecated for iconv and mbstring.

List of all changed functions in PHP 5.6 can be found here.

List of all New functions in PHP 5.6 can be found here.

While the PHP team is working on PHP6, PHP7 and PHPNG, I would say PHP 5.6 has covered a shipped with a solid amount of improvements and feature additions.

Don’t forget to let us know of any questions or comments you may have in the feed below.

Tagged with: , , , , , , ,
Posted in PHP

10 HTML Tags You May Not Be Using

As a front-end developer you no doubt use HTML constantly and probably feel it doesn’t have any more unknowns. Nevertheless, the way it has evolved (in particular with the advent of HTML5) may surprise you at times. In this article, I’ll show you 10 HTML tags you may not be using or maybe even aren’t yet aware of that help to increase the semantics and maintainability of your web pages.

1. <meter>

At some point we may need to express a measure on a web page. It could be anything from the result of an exam to disk usage. HTML5 introduced a new element called <meter> that represents a scalar measurement within a known range, or a fractional value.

Based on this element’s definition in the specification, <meter> is not good to measure something like external temperature — because it doesn’t have a fixed range (you can define, it but it’s arbitrary). This element has several attributes. The most common ones are: value, min, and max. The first is used to indicate the measure, while the other two are used to specify the range. So, if you want to indicate that a hard disk of 500Gb has 300Gb occupied, you can write:

1
<meter value="300" min="0" max="500">300Gb of 500Gb</meter> occupied.

2. <progress>

From time immemorial, developers have created widgets to notify users of the progress of a download or task. Today there’s a native HTML5 tag for this called <progress>. It has two attributes: value (to specify the state of the progress) and max (to indicate the maximum value to reach). If the max value isn’t set, a range of 0-1 is assumed and value can be any float within this range. So, to show a progress bar for a task completed at 50% you can write:

1
<progress value="50" max="100">50%</progress>

Or equivalently:

1
<progress value="0.5">50%</progress>

The text inside the element is used as a fallback for older browsers. Generally, this element would not be used statically, but rather would be used in conjunction with JavaScript or CSS animations to indicate continuous progress.

3. & 4. <cite> and <q>

When writing, we often find ourselves quoting a book, an article, or person. On paper we usually use double quotes (“…”) to delimit the quote portion, along with the prepositions from or by to specify who we’re citing or from what source.

In HTML5 we have <q> to specify the quote, and <cite> for the source. Note that until recently <cite> could be used only to indicate a work’s title (book, article, film, etc.), not a person. However, this has been updated so that we can use it for ‘citing’ people too. The <q> tag has an attribute called cite that allows us to indicate the link to the source of the quotation.

Now for an example, let’s say that we want to cite a famous quote from Ezra Pound (my favourite quote). Using HTML, we would write:

1
2
3
We should fight for our rights because, as <cite>Ezra Pound</cite> said,
<q>If a man isn't willing to take some risk for his opinions, either his
opinions are no good or he's no good.</q>

5. <pre>

The <pre> element allows us to show preformatted text as it appears in the source. What this means is that multiple whitespace characters won’t be collapsed into one (changing the default manner that browsers handle whitespace). This tag is ideal when you need to show a snippet of code because it helps preserve indentation. For example, in a page we may have something like this:

1
2
3
4
5
6
7
8
9
<pre><code>
function sayHello(name) {
    for (var i = 0; i < 3; i++) {
        console.log('Hi ' + name + '!');
    }
}
sayHello('Aurelio');
</code></pre>

6. & 7. <kbd> and <samp>

If you’re a tech writer, you might often discuss tools and techniques that require the use of terminal or shell commands. So, chances are that you also want to show the result of these commands. This situation is the perfect fit for <kbd> and <samp>. The former represents a user input such as but not restricted to keyboard input. The latter represents a sample of the output of a program or a computing system. These elements works well with the previously presented pre element. An example of the use of these elements, similar to an example used in the spec, is the following:

1
2
3
<samp><span>jdoe@mowmow:~$</span> <kbd>ssh demo.example.com</kbd>
Last login: Tue Apr 12 09:10:17 2005 from mowmow.example.com
<span class="prompt">jdoe@demo:~$</span> _</samp>

8. <small>

Before HTML5, the <small> element was only a presentational one, used to write words using a smaller font. In HTML5 <small> has some semantic value. Now the <small> element represents text often found in small print like disclaimers, caveats, legal restrictions, or copyrights. An example of its use is shown below:

1
This article is offered to you by Aurelio De Rosa <small>Copyright © 2014</small>

9. <output>

The <output> tag represents the result of a calculation. Its main attribute is for, which contains a list of space-separated IDs of the elements that went into the calculation, or that otherwise influenced the calculation. This element is exactly what you need if you have a website that offers something like automobile pricing or life insurance quotes.

To see it in action, imagine there’s a widget on your company’s website where users can specify the amount to invest in your company in exchange for a certain percentage in return every year. Based on this situation, you may have a form, using the output element as shown below:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
<form id="form-calculation">
   
  <label for="amount">Amount:</label> <input id="amount" type="number"/>
  <label for="percentage">Percentage:</label>
  <input id="percentage" type="number">
  <label for="years">Years:</label>
  <input id="years" type="number">
  <input type="submit" value="Submit">
  <label for="total">Total:</label>
  <output id="total" for="amount percentage years"></output>
</form>
<script>
function calculateTotal(amount, percentage, years) {
   for(var i = 0; i < years; i++) {
      amount += amount * percentage / 100;
   }
   return amount;
}
document.getElementById('form-calculation').addEventListener('submit', function(event) {
      event.preventDefault();
      document.getElementById('total').textContent = calculateTotal(
         Number(document.getElementById('amount').value),
         Number(document.getElementById('percentage').value),
         Number(document.getElementById('years').value)
      );
   },
   false
);
</script>

10. <dfn> (The icing on the cake)

Before talking about this element, I want to confess something. When I decided to write this article, I started thinking about what tags to include. When I arrived at the 9th tag in my list, I thought it would have been nice to add something special as a conclusion. So, I decided to scan the list of HTML5 tags and here is my reaction.

Now that you know how I stumbled upon <dfn>, we can move on and describe this tag. The dfn element allows us to define a term. In its simplest form, it contains the term you want to define, and then wrap it with a paragraph, a description list group, or a section containing the definition. To understand the concept, let’s say that we’re writing a page where we’re describing HTML, and we want to define it. To do that using the <dfn> tag, we can write:

1
<dfn>HTML</dfn> is the primary language for marking up web content.

In this case, we’ve defined the term HTML, which is an abbreviation. So, we could enhance our markup further by writing:

1
<dfn><abbr title="HyperText Markup Language">HTML</abbr></dfn> is the primary language for marking up web content.

To choose what is the term defined, the standard specifies a priority list made of 3 points. The priority goes to anything specified in the title attribute of the <dfn>tag. Then, we have whatever is defined in an abbr element child of dfn (as shown in the second example). The last priority goes to the text of the dfn element (as shown in the first example).

In Conclusion

In this article we’ve discussed a number of HTML tags that are less used, and often forgotten. I suggest you read the complete list of HTML tags available from time to time. In this way you’ll refresh your knowledge of semantic elements, and maybe you’ll find a surprise along the way (as I did with the <dfn> tag).

Tagged with: , ,
Posted in HTML

12 Greatest Programmers of all Time

A programmer is a person who can create and modify computer programs. No matter what type of programmer one may be, each and every contributes something to the society, no matter how trivial. Yet, there are those few who have contributed beyond what a single programmer usually does in an entire lifetime. These programmers are pioneers in their respective areas and have each contributed something that has completely changed the way human’s access information and media. So without further ado, here we present the 12 greatest programmers of all time:

 

12. Ada Lovelace

Ada Lovelace

Augusta Ada King, more commonly known as Ada Lovelace, was an English mathematician and the world’s first computer programmer and was chiefly known for her work on Charles Babbage’s early mechanical general-purpose computer, the Analytical Engine. The notes she created for the Analytical Engine include what is recognized as the very first algorithm created solely for the intent of being processed by a machine or in other words, the world’s first computer program.

Ada was a gifted girl from the beginning with an uncommon mindset who predicted that one day computers would transcend from simply being used for crunching numbers — totally against the popular opinion of that time. Ada’s main inspiration came from her father and without her, who knows how long it would take for another person to design a computer program.

 

11. Niklaus Wirth

Niklaus Wirth

Niklaus Emil Wirth is a Swiss computer scientist who is regarded as a pioneer of computer programming among other fields in software engineering. He is best known for designing several programming languages, including the highly popular Pascal, Euler, Algol W, Modula, Modula-2, Oberon, Oberon-2, and Oberon-07. He also designed the simple programming language PL/0 to illustrate compiler design which formed the basis for many university compiler design classes.

Niklaus had previously worked on part of the design and implementation team for the Lilith and Oberon operating systems as well as the Lola digital hardware design and simulation system. Wirth’s pioneering work and development of innovative computer languages helped him win the prestigious Turing Award in 1984.

 

10. Bill Gates

Bill Gates

Arguably one of the most popular computer programmers of all time, Bill Gates is an American business magnate, computer programmer, PC pioneer, investor, and philanthropist. He is the co-founder, ex-executive officer and current chairman of Microsoft, which is the world’s largest personal-computer software company. He is the best-known entrepreneurs of the personal computer revolution and helped develop Windows, which is the most used operating system in the world.

For the first 5 years at Microsoft, aside from handling the business side of the company, Gates also personally oversaw every single code that the company sent out, often fixing ones he deemed incorrect or buggy. Aside from his programming skills, he is widely praised for his generosity and keen investment planning, but is highly criticized due to his anti-competitive business tactics.

 

9. James Gosling

James Gosling Java

James Arthur Gosling is a Canadian computer scientist and an officer of the order of Canada. He has coded quite a number of programs but is widely known for his creation of the highly successful and commonly used Java programming language in 1994 as well as its original virtual machine and compiler. He credits his creation towards his graduate student days where he created a p-code virtual machine for the lab’s DEC VAX computer, so that his professor could run UCSD Pascal programs and then realized that the architecture-neutral execution for widely distributed programs could be achieved by a similar technique.

James has also made major contributions to several other software systems, such as NeWS and Gosling Emacs. Due to his extra-ordinary achievements Gosling was elected to Foreign Associate member of the United States National Academy of Engineering.

 

8. Guido van Rossum

Guido van Rossum Python

Guido van Rossum is a Dutch computer programmer who is the author of the popular Python programming language that is wildly used today. His creation of Python lead him to being declared a “Benevolent Dictator For Life” the In the Python community which means that he continues to oversee the Python development process, making decisions where necessary, forever.

Rossum had developed Python while working at Google, where he also created Mondrian (a code review system internally used by the Google) and Rietveld. After working for Google for 7 years, he is now working at Dropbox. Rossum has been recognized as a distinguished engineer by the Association for Computing Machinery and also received the NLUUG Award in May 2003.

 

7. Ken Thompson

Kenneth Lane Thompson

Kenneth Lane Thompson, or simply “Ken” as he is called by the hacker community, is an American pioneer of computer science. Thompson had designed and implemented the original Unix operating system and also invented the B programming language (the direct predecessor to the famous C programming language), and was one of the early developers of the Plan 9 operating systems.

Since 2006, Thompson has also co-invented the Go programming language while working at Google. Ken’s other contributions included his work on regular expressions, early computer text editors QED and ed, the definition of the UTF-8 encoding, and even his work on computer chess that included creation of endgame tablebases and the chess machine Belle.

 

6. Donald Knuth

Donald Knuth

Donald Ervin Knuth is an American computer scientist and mathematician as well as a Professor Emeritus (retired professor) at Stanford University. Knuth has been dubbed as the “Father of the Analysis of Algorithms” as he has contributed to the development of rigorous analysis of the computational complexity of algorithms and systematized formal mathematical techniques for it.

Knuth has also popularized the asymptotic notation and he is also the creator of the TeX computer typesetting system and the METAFONT font definition language and rendering system. He has contributed to several branches of theoretical computer science and has also created the Computer Modern family of typefaces.

 

5. Brian Kernighan

Brian Kernighan UNIX

Brian Wilson Kernighan is a Canadian computer scientist who worked at Bell Labs alongside Ken Thompson and Dennis Ritchie. He is the co-creator and developer of UNIX. He is also co-author of the AWK and AMPL programming languages. Kernighan is currently a Professor and the Undergraduate Department Representative at the Computer Science Department of Princeton University.

Kernighan became famous by co-authoring the very first book on the C programming language and by authoring many UNIX programs such as ditroff, and cron for Version 7 Unix. His other notable work include his popular criticisms for Pascal called “Why Pascal is Not My Favorite Programming Language”.

 

4. Tim Berners-Lee

Tim Berners-Lee father of internet

Sir Timothy John “Tim” Berners-Lee is a British computer scientist who is renowned all across the globe because of his creation of the World Wide Web as well as the implementation of the first successful communication between a Hypertext Transfer Protocol (HTTP) client and server via the Internet in November, 1989.

Tim has won multiple awards for his pioneering ingeniousness such as becoming one of only six members of the World Wide Web Hall of Fame and one of five Internet and Web pioneers who have been awarded the inaugural Queen Elizabeth Prize for Engineering. He is also the holder of the Founders Chair at the MIT Computer Science and Artificial Intelligence Laboratory.

 

3. Bjarne Stroustrup

Bjarne Stroustrup c++

Bjarne Stroustrup is a Danish computer scientist who is credited for the creation and the development of the widely used and highly successful C++ programming language. He not only invented it, but also evolved it, all by himself, by writing its early definitions, producing its first implementation, formulating its design criteria, designing all its major facilities, processing extension proposals for standards committee and its standard textbook.

Bjarne is currently working as a Professor and holder of the College of Engineering Chair in Computer Science at Texas A&M University.

 

2. Linus Torvalds

Linus Torvalds Linux

Linus Benedict Torvalds s a Finnish American software engineer, who was the principal driving force behind the development of the Linux kernel. Its creation itself is attributed towards him and he later became the chief architect of the Linux kernel, and is now the project’s coordinator.

Linus was honored with the 2012 Millennium Technology Prize by the Technology Academy Finland because of his creation of a new open source operating system for computers leading to the wide spread use of Linux kernel. He also created the ever popular distrbuted version control system called Git in 2005,as well as the diving log software Subsurface.

 

1. Dennis Ritchie

Dennis Ritchie C language creator

Dennis MacAlistair Ritchie was an American computer scientist who is credited for shaping and pioneering the digital era. He created the most commonly used C programming language that is used today in various software applications, embedded system development, operating systems, and has influenced most modern programming languages.

Dennis also co-created the UNIX operating system. For his work, in 1983 he received the Turing Award from the ACM, the Hamming Medal in 1990 from the IEEE and in 1999 the National Medal of Technology from President Clinton. He was the head of Lucent Technologies System Software Research Department when he retired in 2007. He passed away on October 12, 2011 causing the Fedora 16 Linux distribution to be released in his memory.

 

Which of the above mentioned greatest programmers of all time has influenced you the most? Share your thoughts with us in the comments section below!

Tagged with: , ,
Posted in APIs, ASP, CSS, Frameworks, HTML, Javascript, PHP, Scripts, Snippets, SQL

Browser Trends September 2014: Chrome Is the Top Mobile Browser

http://images.teinteresa.es/tecno/internet/Logo-Google-Chrome_TINIMA20131218_0904_5.jpg

Last month’s browser trends report was all about mobiles. It’s a recurring theme in the latest figures from StatCounter.

Worldwide Desktop & Tablet Browser Statistics, July to August 2014

The following table shows browser usage movements during the past month.

Browser July August change relative
IE (all) 21.36% 20.31% -1.05% -4.90%
IE11 9.08% 9.10% +0.02% +0.20%
IE10 3.34% 3.05% -0.29% -8.70%
IE9 3.30% 3.12% -0.18% -5.50%
IE8 5.22% 4.68% -0.54% -10.30%
IE7 0.14% 0.14% +0.00% +0.00%
IE6 0.28% 0.22% -0.06% -21.40%
Chrome 45.39% 46.37% +0.98% +2.20%
Firefox 17.50% 17.48% -0.02% -0.10%
Safari 4.41% 4.42% +0.01% +0.20%
iPad Safari 6.16% 6.38% +0.22% +3.60%
Opera 1.34% 1.42% +0.08% +6.00%
Others 3.84% 3.62% -0.22% -5.70%

Worldwide Desktop & Tablet Browser Statistics, August 2013 to August 2014

The following table shows browser usage movements during the past twelve months:

Browser August 2013 August 2014 change relative
IE (all) 25.53% 20.31% -5.22% -20.40%
IE11 0.02% 9.10% +9.08% +45,400.00%
IE10 11.34% 3.05% -8.29% -73.10%
IE9 5.20% 3.12% -2.08% -40.00%
IE8 8.27% 4.68% -3.59% -43.40%
IE7 0.47% 0.14% -0.33% -70.20%
IE6 0.23% 0.22% -0.01% -4.30%
Chrome 42.85% 46.37% +3.52% +8.20%
Firefox 19.26% 17.48% -1.78% -9.20%
Safari 8.57% 10.80% +2.23% +26.00%
Opera 1.14% 1.42% +0.28% +24.60%
Others 2.65% 3.62% +0.97% +36.60%

The tables show market share estimates for desktop browsers. The ‘change’ column is the absolute increase or decrease in market share. The ‘relative’ column indicates the proportional change, i.e. 10.3% of IE8 users switched browsers last month. There are several caveats so I recommend you read How Browser Market Share is Calculated.

Chrome is the biggest winner and has reverted back to it’s 1% monthly gain. That said, the browser has only achieved 3.5% in the past year so growth has plateaued.

There was little to report for Firefox and Safari although Opera enjoyed a small jump. Version 23 was released recently and, while it still lacks functionality present in the Presto edition, it’s a capable browser which feels faster than Chrome.

Unsurprisingly, Chrome’s gain meant another loss for Internet Explorer. It’s managed to hover above 20% for some time but will almost certainly fall below that threshold before the end of 2014. IE11 may never reach the maximum 13% market share gained by IE10 in October 2013. Despite being a good all-round browser, IE11 is available on fewer platforms and isn’t better than any other application. It also has an image problem; Microsoft has even considered a name change to distinguish the browser from it’s tarnished past. (“Web Explorer” would be more accurate too!)

Question: do you still want to see separate figures for IE6 and IE7 in next month’s report? There’s a hardcore of usage, but the browsers have barely moved in a year and could be summed in a single “IE8-” figure.

Worldwide Mobile Browser Statistics, July to August 2014

Mobile usage increased by 1.2% during August 2014 to reach 30.64% of all web activity. The summer months in the Northern hemisphere may explain some of this gain but it’s impossible to refute the mobile growth trend.

There are several reasons why mobile usage has trebled in two years:

  1. Handset costs. The top end of the market remains eye-wateringly expensive but smartphones are now available with basic payment plans.
  2. Device capability. Larger screens and better processors allow us to use mobiles for activities which would have required a PC a few years ago.
  3. Developing world adoption. Mobile growth in Asia, Africa and South America has exploded — even in places where the PC era passed unnoticed. Many are ahead of Western countries in respect to mobile commerce and micro-payments.

The top mobile browsing applications:

Mobile Browser July August change relative
Chrome 21.53% 22.67% +1.14% +5.30%
Android 22.91% 22.35% -0.56% -2.40%
iPhone 22.94% 21.75% -1.19% -5.20%
Opera Mini/Mobile 11.11% 11.15% +0.04% +0.40%
UC Browser 9.56% 10.33% +0.77% +8.10%
Nokia Browser 3.87% 3.89% +0.02% +0.50%
IEMobile 2.40% 2.34% -0.06% -2.50%
Others 5.68% 5.52% -0.16% -2.80%

As I predicted last month, Chrome has overtaken both the iPhone and stock Android apps to become the number one browser on mobile devices. A considerable achievement given that Chrome accounted for just 4% of the mobile market this time last year and the stock Android browser has only fallen 6% in the same period.

Chrome is now the top mobile and desktop browser. It deserves that place but should we be concerned about Google’s dominance? Hopefully they’ll remember what happened to the last company who enjoyed a browser monopoly.

Tagged with: , ,
Posted in CSS, HTML, Javascript, PHP

Add www To All URLs With htaccess

For SEO it is important to use a set standard of how you present your domain. The most popular approach is to use the sub-domain www. Many people don’t know this but http://www.domain.com is the same as http://domain.com, you will be sent to the same page but they will have different URLs.

For SEO if a search engine saw http://www.domain.com it will crawl this page, check the content and index the content. Then later if it goes and crawls http://domain.com the search engines will see the same content but on different URLs and think it is duplicate content and therefore will penalise this domain in the search engine ranking.

Consistent

The best way to get around this problem is to make sure that all your URLs on your site use a consistent URL format either http://www.domain.com or domain.com. It makes no difference which format you choose, the search engine just worries about duplicate content.

Use www

I prefer to make sure all my domains use www sub-domain, this is the format most people are used to seeing on search engines and web sites. If people are used to seeing it then they will not worry about the URL.

Now that you have chosen your preferred format and changed all your links to your site to use this format then you are done, right, wrong! If you stick just with this you run the risk of someone linking to you but forgetting to put a www on the front, the search engines will then crawl through this link and see duplicate content and penalise your domain.

To combat this problem you have a couple of options the best solution is to perform a check of the URL on each page if it doesn’t contain the www then perform a 301 redirect to your domain with the www sub-domain. The best way of using this solution is to use htaccess, this will run before any pages are loaded and allows you to change the URL with a 301 redirect.

.htaccess To Redirect URLs

To use htaccess to redirect URL just copy and paste the snippet below and replace example.com with your domain.

RewriteEngine On
RewriteCond %{HTTP_HOST} ^example.com$ [NC]
RewriteRule ^(.*)$ http://www.example.com/$1 [L,R=301]
Tagged with: , , , ,
Posted in APIs, ASP, Frameworks, PHP

Testing Your Web Designs in Different Browsers

multiple-browsers-testingWeb site themes offer web site owners a lot of flexibility when it comes to designing their site, but even the greatest web site theme or design doesn’t come without issues, such as how it interacts with different programs. For example, if it’s a flash based site, how does it operate on older versions of flash? Another issue that could arise is that with Firefox supporting Third-Party plugins there may be additional issues that result from that. While it would be impossible to download and install every possible Firefox plugin, downloading and installing the top 10 most popular ones wouldn’t be that difficult. The most popular user installed current version plugins can be found atLatestVersionPlugin.com.

internet-browsers

When to Test Your Design?

The best possible time to check your web design is early on in the implementation and construction phase. Basically you want to know right away how your site design functions within each browser, and while these is a time consuming processing, it’s also a worthwhile investment. Because a bad web design/site will result in your visitors, one leaving before they should and two not returning or spreading to word about your site. Which as we know will lead to a drop in traffic and income.

What to Test?

Before you start testing your new web site design you’ll need to create a list of items to test, one of the things you need to consider is any updates you did to the code. You’ll need to see if it functions in the same manner as before.

Things that you must test are:

  • Make sure that you are covering all the modern browsers i.e. latest versions of Chrome, Opera, Firefox, Safari and Internet Explorer (IE). You would find that most of them come with a proper updating system and testing the latest one can give you results for the older versions too.
  • You need to include all the previous versions of IE from 7 onwards. If you have access to windows machine then that won’t be difficult, otherwise you may need to use a browser testing service or emulator such asbrowserstack.com.
  • Testing your sites compatibility on mobile browsers is crucial now as a significant portion of web traffic is generated from mobile devices.

Which pages to test?

  • If you need to choose which pages should be tested the answer would depend upon the size of the web site and the number of pages. If there are huge number of pages then it’s okay to test only the ones which have different unique designs features. Always test against various screen resolution. By resizing the browser window while testing you can easily accomplish it. All these tests are done as because people have different taste and they use different browsers as per their need.

With a little bit of preparation and time, the shift to a new website can be seamless like any minor update that you do on your website.

Tagged with: , , , , ,
Posted in APIs, ASP, CSS, Frameworks, HTML, Javascript, PHP, Scripts

SQL vs NoSQL Database Differences Explained with few Example DB

Most of you are already familiar with SQL database, and have a good knowledge on either MySQL, Oracle, or other SQL databases. In the last several years, NoSQL database is getting widely adopted to solve various business problems.

It is helpful to understand the difference between SQL and NoSQL database, and some of available NoSQL database that you can play around with.

SQL vs NoSQL: High-Level Differences

  • SQL databases are primarily called as Relational Databases (RDBMS); whereas NoSQL database are primarily called as non-relational or distributed database.
  • SQL databases are table based databases whereas NoSQL databases are document based, key-value pairs, graph databases or wide-column stores. This means that SQL databases represent data in form of tables which consists of n number of rows of data whereas NoSQL databases are the collection of key-value pair, documents, graph databases or wide-column stores which do not have standard schema definitions which it needs to adhered to.
  • SQL databases have predefined schema whereas NoSQL databases have dynamic schema for unstructured data.
  • SQL databases are vertically scalable whereas the NoSQL databases are horizontally scalable. SQL databases are scaled by increasing the horse-power of the hardware. NoSQL databases are scaled by increasing the databases servers in the pool of resources to reduce the load.
  • SQL databases uses SQL ( structured query language ) for defining and manipulating the data, which is very powerful. In NoSQL database, queries are focused on collection of documents. Sometimes it is also called as UnQL (Unstructured Query Language). The syntax of using UnQL varies from database to database.
  • SQL database examples: MySql, Oracle, Sqlite, Postgres and MS-SQL. NoSQL database examples: MongoDB, BigTable, Redis, RavenDb, Cassandra, Hbase, Neo4j and CouchDb
  • For complex queries: SQL databases are good fit for the complex query intensive environment whereas NoSQL databases are not good fit for complex queries. On a high-level, NoSQL don’t have standard interfaces to perform complex queries, and the queries themselves in NoSQL are not as powerful as SQL query language.
  • For the type of data to be stored: SQL databases are not best fit for hierarchical data storage. But, NoSQL database fits better for the hierarchical data storage as it follows the key-value pair way of storing data similar to JSON data. NoSQL database are highly preferred for large data set (i.e for big data). Hbase is an example for this purpose.
  • For scalability: In most typical situations, SQL databases are vertically scalable. You can manage increasing load by increasing the CPU, RAM, SSD, etc, on a single server. On the other hand, NoSQL databases are horizontally scalable. You can just add few more servers easily in your NoSQL database infrastructure to handle the large traffic.
  • For high transactional based application: SQL databases are best fit for heavy duty transactional type applications, as it is more stable and promises the atomicity as well as integrity of the data. While you can use NoSQL for transactions purpose, it is still not comparable and sable enough in high load and for complex transactional applications.
  • For support: Excellent support are available for all SQL database from their vendors. There are also lot of independent consultations who can help you with SQL database for a very large scale deployments. For some NoSQL database you still have to rely on community support, and only limited outside experts are available for you to setup and deploy your large scale NoSQL deployments.
  • For properties: SQL databases emphasizes on ACID properties ( Atomicity, Consistency, Isolation and Durability) whereas the NoSQL database follows the Brewers CAP theorem ( Consistency, Availability and Partition tolerance )
  • For DB types: On a high-level, we can classify SQL databases as either open-source or close-sourced from commercial vendors. NoSQL databases can be classified on the basis of way of storing data as graph databases, key-value store databases, document store databases, column store database and XML databases.

SQL Database Examples

1. MySQL Community Edition

MySQL database is very popular open-source database. It is generally been stacked with apache and PHP, although it can be also stacked with nginx and server side javascripting using Node js. The following are some of MySQL benefits and strengths:

  • Replication: By replicating MySQL database across multiple nodes the work load can be reduced heavily increasing the scalability and availability of business application
  • Sharding: MySQL sharding os useful when there is large no of write operations in a high traffic website. By sharding MySQL servers, the application is partitioned into multiple servers dividing the database into small chunks. As low cost servers can be deployed for this purpose, this is cost effective.
  • Memcached as a NoSQL API to MySQL: Memcached can be used to increase the performance of the data retrieval operations giving an advantage of NoSQL api to MySQL server.
  • Maturity: This database has been around for a long time and tremendous community input and testing has gone into this database making it very stable.
  • Wide range of Platforms and Languages: MySql is available for all major platforms like Linux, Windows, Mac, BSD and Solaris. It also has connectors to languages like Node.js, Ruby, C#, C++, C, Java, Perl, PHP and Python.
  • Cost effectiveness: It is open source and free.

2. MS-SQL Server Express Edition

It is a powerful and user friendly database which has good stability, reliability and scalability with support from Microsoft. The following are some of MS-SQL benefits and strengths:

  • Integrated Development Environment: Microsoft visual studio, Sql Server Management Studio and Visual Developer tools provide a very helpful way for development and increase the developers productivity.
  • Disaster Recovery: It has good disaster recovery mechanism including database mirroring, fail over clustering and RAID partitioning.
  • Cloud back-up: Microsoft also provides cloud storage when you perform a cloud-backup of your database

3. Oracle Express Edition

It is a limited edition of Oracle Enterprise Edition server with certain limitations. This database is free for development and deployment. The following are some of Oracle benefits and strengths:

  • Easy to Upgrade: Can be easily upgraded to newer version, or to an enterprise edition.
  • Wide platform support: It supports a wide range of platforms including Linux and Windows
  • Scalability: Although the scalability of this database is not cost effective as MySQL server, but the solution is very reliable, secure, easily manageable and productive.

NoSQL Database Examples

1. MongoDB

Mongodb is one of the most popular document based NoSQL database as it stores data in JSON like documents. It is non-relational database with dynamic schema. It has been developed by the founders of DoubleClick, written in C++ and is currently being used by some big companies like The New York Times, Craigslist, MTV Networks. The following are some of MongoDB benefits and strengths:

  • Speed: For simple queries, it gives good performance, as all the related data are in single document which eliminates the join operations.
  • Scalability: It is horizontally scalable i.e. you can reduce the workload by increasing the number of servers in your resource pool instead of relying on a stand alone resource.
  • Manageable: It is easy to use for both developers and administrators. This also gives the ability to shard database
  • Dynamic Schema: Its gives you the flexibility to evolve your data schema without modifying the existing data

2. CouchDB

CouchDB is also a document based NoSQL database. It stores data in form of JSON documents. The following are some of CouchDB benefits and strengths:

  • Schema-less: As a member of NoSQL family, it also have dynamic schema which makes it more flexible, having a form of JSON documents for storing data.
  • HTTP query: You can access your database documents using your web browser.
  • Conflict Resolution: It has automatic conflict detection which is useful while in a distributed database.
  • Easy Replication: Implementing replication is fairly straight forward

3. Redis

Redis is another Open Source NoSQL database which is mainly used because of its lightening speed. It is written in ANSI C language. The following are some of Redis benefits and strengths:

  • Data structures: Redis provides efficient data structures to an extend that it is sometimes called as data structure server. The keys stored in database can be hashes, lists, strings, sorted or unsorted sets.
  • Redis as Cache: You can use Redis as a cache by implementing keys with limited time to live to improve the performance.
  • Very fast: It is consider as one of the fastest NoSQL server as it works with the in-memory dataset.
Tagged with: , , , , , , , ,
Posted in SQL

Enter your email address to follow this blog and receive notifications of new posts by email.

Join 140 other followers

Follow me on Twitter
Community
Follow

Get every new post delivered to your Inbox.

Join 140 other followers