Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

SitePoint PHP Blog:
How to Read Big Files with PHP (Without Killing Your Server)
Nov 21, 2017 @ 19:19:27

On the SitePoint PHP blog, there's a tutorial posted showing you how to deal with large files without "killing your server". In this case, it's not about the upload process but about the handling of large files on the server side.

It’s not often that we, as PHP developers, need to worry about memory management. The PHP engine does a stellar job of cleaning up after us, and the web server model of short-lived execution contexts means even the sloppiest code has no long-lasting effects.

There are rare times when we may need to step outside of this comfortable boundary — like when we’re trying to run Composer for a large project on the smallest VPS we can create, or when we need to read large files on an equally small server. It’s the latter problem we’ll look at in this tutorial.

They start off by describing how they plan to measure the success of the improved file handling, mostly around the memory usage required to work with the file. It then gets into some of the options available including:

  • reading files line by line
  • piping between files
  • using filters

The last option, the filters, seems to be the best one. He uses this one and customizes the handling with different configurations and custom protocols. All related code is included in the post and is avaialble on GitHub.

tagged: read big file memory consumption filter stream tutorial

Link: https://www.sitepoint.com/performant-reading-big-files-php/

SitePoint PHP Blog:
Arbitrary Precision and Big Numbers in PHP
Jan 30, 2014 @ 16:20:46

The SitePoint PHP blog has a new post by Taylor Ren looks at big numbers in PHP and the functionality it has to handle arbitrary precision via three modules - GMP. BC Math and php-bignumbers.

In this article, we will review the PHP capability to provide arbitrary precision number calculation / big integer calculation by reviewing 3 PHP modules: GMP, BC Math and php-bignumbers. We will demonstrate two real-world examples to see the powers/limitations of each. The first one will be calculating PI to arbitrary precision – well, for the sake of the article, we will restrict the precision, say, to 1000 digits; the second will be a simple demonstration on RSA encryption/decryption.

He briefly looks at how to get the tools installed (via at-get or Composer) and a sample script to ensure that they're all included correctly and working. He includes a comparison between the three libraries, listing both strengths and weaknesses relative to the others. He then gets a bit more in-depth and shows how to calculate PI with each option (code is on GitHub) and the results of the benchmarking. He also includes a second example of calculating the RSA algorithm based on their process.

tagged: arbitrary precision big number gmp phpbignumbers bcmath tutorial

Link: http://www.sitepoint.com/arbitrary-precision-big-numbers-php/

Florin Patan:
Next big thing in PHP
Feb 27, 2013 @ 18:19:47

Florin Patan has posted about what he calls the next big thing in PHP - his observations of the current state of the language/community and what could be coming down the road.

What's the next big thing in PHP? Or more accurately, how do you get to wish/want for a next big thing in PHP? PHP currently is seen as a jack of all trades, master none by most of people outside of PHP world and it's starting to look the same way for people who are using it as well. How did we got there?

He spends a lot of the post talking about the future of PHP, though - what could be coming along with a PHP 6 release. He suggests that, with the way things are going, PHP could not be around too much longer if something dosen't change. He also makes several suggestions to the core PHP developers about what they could do to help the situation including strong typed variables, a "smarter parser" and a poll for PHP.net asking the users what they want in the language.

This should be the next big thing in PHP. Collaboration and better community interface for both worlds, users and devs. Help us help you on PHP6, help us making a better world for everyone using PHP.
tagged: next big thing opinion language php6 feature community

Link:

Sephiroth.it:
PHP5 - a big failure?
Feb 17, 2006 @ 12:44:26

New today from Gabriele Farina on Sephiroth.it, there's a post that asks the question, "Is PHP5 a big failure?"

PHP 5 has been presented as a revolution, a lot of new features have been added and a lot of projects have been made. But only a small group of hosters seem interested in supporting PHP 5 on their web servers. It is not so useful to have a beautiful programming language to use if we can't apply it to production environments.

We MUST use PHP 5 to help it growing until it become the standard...

PHP5 has seen a pretty slow adoption rate so far, but according to some statistics, its usage has been picking up lately - even among hosting providers.

tagged: php5 big failure must use production hosting php5 big failure must use production hosting

Link:

Sephiroth.it:
PHP5 - a big failure?
Feb 17, 2006 @ 12:44:26

New today from Gabriele Farina on Sephiroth.it, there's a post that asks the question, "Is PHP5 a big failure?"

PHP 5 has been presented as a revolution, a lot of new features have been added and a lot of projects have been made. But only a small group of hosters seem interested in supporting PHP 5 on their web servers. It is not so useful to have a beautiful programming language to use if we can't apply it to production environments.

We MUST use PHP 5 to help it growing until it become the standard...

PHP5 has seen a pretty slow adoption rate so far, but according to some statistics, its usage has been picking up lately - even among hosting providers.

tagged: php5 big failure must use production hosting php5 big failure must use production hosting

Link:

Big Nerd Ranch Blog:
XML in PHP 5
Nov 19, 2005 @ 11:26:38

David Sklar has this pointer on his blog today to a new post on the Big Nerd Ranch blog today dealing with XML and PHP5.

Now that PHP 5 is becoming more and more prevalent over its predecessors, some really good books that cover PHP need revisions. Nowhere is this more true than with XML-related topics, where PHP 5 has a completely different way of working with XML — and, in fact, the mechanisms from PHP 4 will no longer work.

In this article, we’ll be looking at one way to build and parse an XML tree using the new methods in PHP 5.

They look at a generic XML document they'll use to test and move quickly into a way to create it using the DOM functionality in PHP. From there, they use a simple ten-line script to parse it and echo it back out...

tagged: big nerd ranch PHP5 XML big nerd ranch PHP5 XML

Link:

Big Nerd Ranch Blog:
XML in PHP 5
Nov 19, 2005 @ 11:26:38

David Sklar has this pointer on his blog today to a new post on the Big Nerd Ranch blog today dealing with XML and PHP5.

Now that PHP 5 is becoming more and more prevalent over its predecessors, some really good books that cover PHP need revisions. Nowhere is this more true than with XML-related topics, where PHP 5 has a completely different way of working with XML — and, in fact, the mechanisms from PHP 4 will no longer work.

In this article, we’ll be looking at one way to build and parse an XML tree using the new methods in PHP 5.

They look at a generic XML document they'll use to test and move quickly into a way to create it using the DOM functionality in PHP. From there, they use a simple ten-line script to parse it and echo it back out...

tagged: big nerd ranch PHP5 XML big nerd ranch PHP5 XML

Link:


Trending Topics: