Как держать форму. Массаж. Здоровье. Уход за волосами

Амвросия upcoming php. Амвросия

Just got released yesterday, and I thought this might be a good time to list some of the new things that are coming, and how it could benefit you. Even though its a minor release, a lot of new features made it in and from a marketing standpoint it should have really been 6.0, if you"d ask me.

Namespaces

A subject touched and trialed many times in PHP, namespaces. This feature has been responsible for the longest discussions on PHP-DEV, but finally a consensus has arrived on how this is going to work.

The biggest benefit namespaces will provide is shortening of long classnames. To make sure that your class libraries can plug into foreign code, it has always been recommended to prefix your classes, for example "Zend_DB_Connection". This can however lead to very long names. Namespaces fixes this by grouping classes together. The full-on classname becomes Zend::DB:Connection, and by placing "use Zend::DB" on top of your code, the "Connection" class can be referenced with just that name.

foo (); ?>

Using namespaces, its also possible to alias classnames.

Furthermore, constants and functions can also be namespaced, but they cannot be directly imported. This means that if you create a function "myFunction" in the "Connection" file mentioned earlier, you cannot import Zend::DB:myFunction, but you can import Zend::DB and reference the function as DB:myFunction().

It is recommended to always place your "use" statements on the beginning of any file, and they will be in effect for the complete file. Note that (AFAIK) this is the first language feature in PHP where the filename holds relevance to the execution, and this can cause some issues for people who like to concatenate their sourcefiles for faster loading. This holds true for both the "namespace" and the "use" statements.

__callStatic

Using the magic function __call, calls to undefined methods could be intercepted and handled in a different way. PHP 5.3 adds __callStatic, which adds the same functionality to static method calls.

"Hi! You just called the method " $name ", but it doesn"t exist. Perhaps you mistyped" ; } } MyClass :: unknownMethod ("hii!" ); ?>

Of course, there"s better usages than lame error messages. (documentation)

Closures

My personal favourite. Closures (or: Lambda functions) allow you to create in-line functions. Many languages already have this feature, and if you ever did any javascript programming, you probably already used it without knowing about it.

__invoke

PHP 5.3 also adds another magic method, allowing you to treat your own objects as if they were closures.

"I"m not really a closure, but you can treat me as such \n " ; } } $closure = new MyCustomClosure (); $closure (); ?>

My #1 feature request is to make sure both classes using __invoke and actual closures implement an interface, this would allow us to easily identify an object as invokable. (e.g.: an Invokable or Callable inteface). This has been requested on the PHP internals mailing list, as we speak.

Phar

Phar is PHP"s answer to java"s JAR files. A PHAR file is a compressed archive and can contain a complete PHP application. This is really cool, as it would allow utilities like PHPMyAdmin to be distributed and used as a single file.

I"m quite excited to use this and see widespread adoption across ISP"s. The best part is that you don"t need the extension to make use of it, but it will run better and faster if it is.

When it is installed, it will allow referencing files from the phar using for example: ```

Other significant additions

  • date_add() , date_sub() , date_diff() and their OOP equivalents.
  • A garbage collector! No documentation on this yet.
  • Lots of new SPL classes, such as SplStack , and SqlQueue .
  • The __DIR__ constant, which can be used as a replacement to the often used: dirname(__FILE__). This allows for example easy file-inclusion and could be optimized by for example APC, which was not easily possible with dirname(__FILE__).
  • New process control functions, for example allowing you to catch process signals from the operation systems while avoiding the (now depreciated) declare(ticks=1) statement.

Conclusion

Its great to see PHP is an alive language, and especially language improvements such as closures and namespaces bring PHP on par with other popular scripting languages. This stuff definitely makes me a happy person. We won"t be using 5.3 in production, as we"ll want to wait till 5.3.1 for things to stabilize a little bit, but I hope that day arrives soon.

5.6 and PHP 7.0. Why update? Why is there so much old PHP out there? How to establish an up-to-date mindset.

This is a long read, including backgrounds, philosophical questions and trivia on the topic. Do not expect code examples.

Why upgrade to PHP 7.2 anyway?

It’s about time. “PHP 5.6” is the last 5 version around and there will be no security patches from December 2018 on. Any new vulnerabilities will not get fixed any more. The same applies to the initial PHP 7 release, version 7.0. It was released in December 2015. The current version is PHP 7.2 and PHP 7.3 is approaching next.

As of September 2018: PHP 5 is still the most used version of PHP. According on who you are asking, you will get different answers:

  • ~80% old PHP according to W3Techs (PHP 7 also includes the deprecated PHP 7.0)
  • ~66% old PHP according to WordPress
  • ~21% old PHP according to Composer

Why the differences? Well, I believe W3Tech is just crawling the web sniffing the X-Powered-By header to get the version in use today. That includes all the public IPs with all the neglected websites out there. As this gives potential hackers information about the PHP version, it"s common practice to suppress or fake this header, so maybe take this number with an extra grain of salt. WordPress is luckily a little ahead, as it is an active community of "web designers", with a big stake in the United States. And of course, Jordi with Composer is ahead, as those PHPeople are mostly "web developers" who care more about such things.

Who is to blame for all the old PHP?

We and other develoPHPers are thrilled by the new PHProfessionality: Composer, Laravel - for us PHP really made the switch to a modern g language. Still PHP has a bad rep for being the Pretty Home Pages language - and that is also still true. PHP was and still is (beside JavaScript) the first web native language to pick to create home pages. And many of those websites are still around. It’s all those tiny businesses and their semi professional web designers . When you receive $200 to build a website for a restaurant, you are not likely to maintain it for the next 10 years.

And it’s the mass of shady shared hosting providers who are keeping the clients locked-in in long term contracts and outdated versions. I can imagine that half of those PHP 5.6 websites could actually be switched off by now. But that’s not the interest of the hosting providers, they are more interested in keeping them around.

What to do about all the old PHP?

What ever the real number of old PHP installations in the whole internet will be, there soon will be tens of thousands of outdated and unprotected PHP servers out there waiting for hackers to take them over. Maybe we should all gather together and raise awareness for the situation so that more PHPeople wake up and update? What about a hashtag like #uPHPgraded ?

Or maybe, even better, that’s a call to establish new business models? Imagine, what would you do with that army of zombie servers? Bitcoin mining or Facebook farming?

Establish an up-to-date mindset

Keeping your own code and the underlying software dependencies up-to-date is more than just a good practice, it’s a requirement. On fortrabbit, we are in this together. We are responsible keeping the infra up-to-date; your are responsible for the code you write and use. Updating keeps your code secure, fast and agile. Our clients are obligated to use up-to-date software by our terms under 4.13 .

The up-to-date mindset requires some thinking ahead and discipline. Technical debt is the keyword here. Consider upfront that all the code your are having out there, will constantly need some attention and time.

It’s easier when you are code maintainer and business owner, like with a start-up or as a freelancer on your own projects. It’s more complicated in bigger structures and in client-agency relationships. Make maintenance an topic early on, include it in your estimates. Raise awareness on the importance to keep your software up-to-date. Reserve a time budget for that upfront.

Wrapping up

I am very happy to see the PHP language under heavy development coming closer to shorter release cycles and even breaking some old habits. It’s alive. Let’s embrace change and move forward.

Seeing technologies you love move forward is an exciting feeling. Another version brings hope of better integrated tools, increased security, and faster ways to complete core tasks, thus making your web application quicker. PHP6’s improvements and and updates are sure to make PHP6 the best version yet.

register_globals, safe_mode, and quote options Removed

register_globals, being the most significant removal, presents a giant security risk as it allows users to modify the querysting to add, change, and remove variable values. It’s highly recommended that you turn this value off on your present PHP build. Magic quotes functions, most notablemagic_quotes_gpc() and magic_quotes(), affect GET, POST, and COOKIE variables. I recommend turning this setting off as well.

Integrated Alternative PHP Cache (APC)

Though this setting will default to off, APC’s caching can significantly increase the speed of your web application. There are currently some great PHP caching libraries available but integrated support can make the system run faster. You can find more information on APC athttp://pecl.php.net/package/APC .

E_STRICT Messages Merged with E_ALL

This move will encourage better programming practices. Of course, you will need to set yourerror_reporting()< level to E_ALL. My websites use E_ALL while on my development server but I change to level 0 (show no errors) when moving then to their hosting server (so that if there is an error, the user can’t see the error).

String Indexes: {} Removed, Becomes Standard Use

As of PHP6, you will no longer be able to use {} to reference the value of a String’s character at a specified position — the standard array position syntax, , will become the only usage.

ASP Style Tags Removed (<% %>)

I have no idea why these were ever implemented. I’ve never used them, nor will I ever.

Increased Unicode Support

PHP does not presently provide adequate Unicode support and PHP6 aims to fix that. Unicode is treated on a per-request basis and cannot be used globally throughout PHP’s functionality — Unicode in PHP becomes inconsistent in usage and takes up more resources.

Other PHP6 Changes:

  • ‘var’ will become an alias of ‘public’ without an E_STRICT warning.
  • GD1 and FreeType1 versions will be removed.
  • Fast CGI will always be on.
  • HTTP_*_VARS variable will be removed.
  • XMLReader and XMLWriter will be integrated.
  • 64-bit integers will be added.
  • Ternary ‘?’ valuable will not be required ($myvar = $_POST[‘myvar’] ?: ‘myvalue’;)
  • foreach multidimensional arrays work (foreach($a as $k=>list($b,$c));)
  • Type-hinted return values (syntax not yet solidified)
  • Hardened PHP patch will be added for increased security.

We’ll continue to eagerly monitor PHP6’s progress!

Seeing technologies you love move forward is an exciting feeling. Another version brings hope of better integrated tools, increased security, and faster ways to complete core tasks, thus making your web application quicker. PHP6"s improvements and and updates are sure to make PHP6 the best version yet.

register_globals, safe_mode, and quote options Removed

register_globals, being the most significant removal, presents a giant security risk as it allows users to modify the querysting to add, change, and remove variable values. It"s highly recommended that you turn this value off on your present PHP build. Magic quotes functions, most notable magic_quotes_gpc() and magic_quotes() , affect GET, POST, and COOKIE variables. I recommend turning this setting off as well.

Integrated Alternative PHP Cache (APC)

Though this setting will default to off, APC"s caching can significantly increase the speed of your web application. There are currently some great PHP caching libraries available but integrated support can make the system run faster. You can find more information on APC at http://pecl.php.net/package/APC .

E_STRICT Messages Merged with E_ALL

This move will encourage better programming practices. Of course, you will need to set your error_reporting()

String Indexes: {} Removed, Becomes Standard Use

As of PHP6, you will no longer be able to use {} to reference the value of a String"s character at a specified position -- the standard array position syntax, , will become the only usage.

ASP Style Tags Removed (<% %>)

I have no idea why these were ever implemented. I"ve never used them, nor will I ever.

Increased Unicode Support

PHP does not presently provide adequate Unicode support and PHP6 aims to fix that. Unicode is treated on a per-request basis and cannot be used globally throughout PHP"s functionality -- Unicode in PHP becomes inconsistent in usage and takes up more resources.

Other PHP6 Changes:

  • "var" will become an alias of "public" without an E_STRICT warning.
  • GD1 and FreeType1 versions will be removed.
  • Fast CGI will always be on.
  • HTTP_*_VARS variable will be removed.
  • XMLReader and XMLWriter will be integrated.
  • 64-bit integers will be added.
  • Ternary "?" valuable will not be required ($myvar = $_POST["myvar"] ?: "myvalue";)
  • foreach multidimensional arrays work (foreach ($a as $k =>list ($b ,$c ));)
  • Type-hinted return values (syntax not yet solidified)
  • Hardened PHP patch will be added for increased security.

We"ll continue to eagerly monitor PHP6"s progress!

PHP is used by 82.4% of all the websites whose server-side programming language we know.

W3Techs.com

At the end of 2016, PHP 7.1 has come up with latest improvised features like,

  • Nullable types
  • Iterable pseudo-type
  • Void return type
  • Class constant visibility modifiers
  • Catching multiple exceptions types
  • Square bracket syntax for list() and the ability to specify keys in list()

Improvement in speed and maturity of PHP libraries are the areas where PHP has improved a lot.

“Version 7 and 7.1 of PHP are not the revolutionary changes that we got in the later 5.x versions. They are however a proof that PHP has stabilized, matured, and does have a predictable path forward.”

Cal Evans, Technical Manager at Zend Technologies and
godfather of the PHP community

(Source: Cloudways)

Entire PHP community is very much happy with the new updated version as all the drawbacks has been removed that were present in the previous version(s) and this helps to establish a new era for enterprise level projects.

Most of the principal companies were not interested with PHP because of its speed.But in 2016; it has spread to millions with its improved featurettes.

I want to develop web applications using PHP. Am I going the right way? Is this the right platform!

Let me tell you some important features, why you will chose PHP for web development and what are the upcoming trends of PHP in 2017.

  1. Equipped with the latest features(stated above)
  2. Open Source, Free, and User-friendly. So, you don’t pay a dime.
  3. Compatible to all the OS and Servers
  4. Includes multiple PHP frameworks
    • MVC coding pattern
    • Object Oriented Programming
  5. Security and Cross Platform.

Probable PHP Trends In 2017

Let’s have a look at the probable PHP trends in 2017,

  1. With the improvement in several important factors like speed and other, PHP 7 may dominate in all aspects of PHP development .
  2. The update and release of major frameworks versions like Symfony, Laravel and Yii which are running with the older version of PHP. These frameworks may completely clinch with PHP 7 important features.
  3. Web hosting service providers may upgrade to PHP 7 with the increase popularity and features.

PHP 7 is the way to go

It increases websites security level adding up speed that gives better user experience.

Share your thoughts with comments below about PHP 7. Features and updates that we might have missed, we will surely put it up in our next article.

Related Posts:


OrangeScrum – Project Management Tool Journey, with the Evolution of PHP