What’s New in PHP 7 You Should Know

PHP7-Calipus

 

Community of PHP developers is eagerly waiting for launch of PHP 7, which was expected to be a reality by mid of October but  finally wait has been over and as per the PHP wiki it’s going to be launched by Today itself.

PHP 7 will be released today after releasing 2 Alpha, 3 Beta and 8 RC versions.

Following snapshot illustrates the history of GA release of PHP 7.

 

PHP-7-Release-History

Some of major features which are included in PHP 7.

 

Performance Improvements

As per performance benchmarks, PHP 7 can handle twice as many requests per second, PHP 5.6 could handle. Zend claims that performance would vary between 25% to 70% for real world applications. Memory usage will also be significantly lower as compared to PHP 5.6 

This is the most important reason you would opt for switching to PHP 7 over PHP 5.6. PHP 7 is based on a project call PHPNG, initially was used by Zend to improve performance of PHP applications.  Zend shared some of their test cases comparing different frameworks and content management systems, some of which have been shown below. You would be amazed to view the difference in speed and that’s something you will get without changing anything at all in your application, obviously apart from fixing some codes if you are using old fashioned line of codes.

 

PHP-7-Magento-Performance-calipus-software

 

PHP-7-Drupal-Performance-calipus-software

 

PHP-7-Wordpress-Performance-calipus-software

 

PHP-7-Framework-Performance-calipus-software

 

PHP-7-SugarCRM-Performance-calipus-software

 

PHP-7-Performance-calipus-software

 

Spaceship Operator

A new operator <=> named as ‘Spaceship Operator’ has been introduced in PHP 7. It will work on all standard values of PHP. But why they named it as ‘Spaceship Operator’ ?? Because that’s what it’s called in most of other languages like Perl, Groovy & Ruby.

If both operands are equal then it will return 0, and will return 1 if left is greater, and -1 if right is greater.

It will have the same precedence as == and !=.

Following snapshot will get you an idea about possible cases.

 

SpaceShip Operator

 

Scalar Type Hints & Return Types

Developers can now declare return type expected by function in PHP 7.

Here is the brief example of syntax :

function foo(): array {
    return [];
}

This does not mean that you have to specify the same for all of your existing code, existing code will keep on running exactly as it is.

Scalar type hinting is another cool feature included in PHP 7. This means that type of functions parameters and return values can be declared as int, float, string and bool.

This will help to prevent programming mistakes as PHP runtime engine will make sure that type of parameters passed and type of return value should be same.

Apart from points mentioned above, some of following noticeable improvements has been included in PHP 7 which we will be covering in our next blog.

 

  • Many fatal errors converted to Exceptions
  • Removed old and unsupported SAPIs and extensions
  • Anonymous Classes
  • Consistent 64-bit support
  • Improved Exception hierarchy
  • The null coalescing operator (??)
  • Zero cost asserts
  • Abstract Syntax Tree
  • Secure random number generator

 




Read More

Apple is going to make some people happy and some people very scared with its new Safari

 

Safari with adblock

Most people loves internet when it’s frictionless: with no pop-ups, no ads, no pre-roll video ads on YouTube, and other different type of advertising.
Apple, the biggest company in America, is taking sides against the companies that want you to click on their ads, watch their videos and subscribe to their newsletters. The next version of the Apple’s mobile Safari browser will support third-party adblocking extensions to grant them a fast and efficient way to block cookies, images, resources, pop-ups, and other unwanted content.
A 2014 report found a 70% increase in people browsing the Internet used ad-blocking software than the year before, and around 41% of the 18-to 29-year-olds surveyed had it installed. But on your smartphone all these ads come right at you.
Apple Safari browser has a 25% share of all mobile browsing, by some estimates. If Apple shuts off 25% of all ads on the web, then some web publishers – and the adtech companies that serve them – will be driven out of business.

And, most users won’t likely be bothered enough to take the time to add a blocker, experts say — even if the fix is as quick as a simple app download. People just sigh and click out.
“Many consumers cite concerns about privacy, ad annoyance and the like but don’t pro-actively take-steps to safegaurd themselves until there has been a ‘breach,'” Jennifer Wise, a digital marketing analyst at Forrester Research, said in an email.

By this new launch of Safari there are two key lines. The first is, “In a worst case scenario, this is Apple against the entire mobile publisher and advertiser system .” Which sounds pretty bad, admittedly.

But the second is, “It may trigger a backlash where certain sites are ‘not optimized for use with Safari’.”

People forget that if Apple makes too many enemies, then companies will start hobbling the web experience for Apple users. And as Apple always promises the best experience for every user, that threat might be real.

Read More