 | News Feed |
 | Jobs Feed |
Sections
|
| feed this: |  |
Ilia Alshanetsky's Blog: PHP's Output Buffering
by Chris Cornutt December 08, 2011 @ 10:01:15
In a new post to his blog Ilia Alshanetsky takes a look at PHP's output buffering feature and some interesting things he found when testing some recent code (hint: it has to do with PHP's "interesting" management of the buffer).
While profiling our application I came across a a rather strange memory usage by the ob_start() function. We do use ob_start() quite a bit to defer output of data, which is a common thing in many applications. What was unusual is that 16 calls to ob_start() up chewing through almost 700kb of memory, given that the data being buffered rarely exceeds 1-2kb, this was quite unusual.
Through a bit more testing he found that, if a buffer provided for content isn't enough, PHP automatically bumps it up by 10kb each time - a waste of resources if you only need a small subset of that. He includes a small patch he made to the PHP core API that allows for defining a custom buffer size and, if it's not enough, bumps up the buffer size by 1kb instead of 10kb.
voice your opinion now!
output buffer increase patch custom size
Sameer Borate's Blog: PHP built in functions map
by Chris Cornutt January 16, 2009 @ 09:31:22
Sameer has put together a few images, the results from the Wordle website when he plugged in the names of the built-in functions included in PHP.
The application is simple. You enter a bunch of text and Wordle does the rest. The applet provides options to change color, font and layout. Just for fun I created a Wordle cloud to display php's built in functions. Two samples are shown below. The size of the font in the cloud is proportional to the number of functions starting with the particular name.
Among the largest on the list are words like "array", "get", "mysql" and "mcrypt". He used a call to the get_defined_functions() method and looped through the "internal" subarray to build his lists.
voice your opinion now!
function wordle builtin output image text size
Kae Verens' Blog: pre-parsing HTML for incorrectly-sized images
by Chris Cornutt July 29, 2008 @ 12:03:55
Kae Verens has a recent blog post that looks at a method for helping to protect users from themselves when working with images - a method for handling ones incorrectly sized.
Every now and then, I get a call from a client who is puzzled why their site is running slow. I would look at their page and see an innocuous image inserted into a paragraph. When I examine the image, though, I see that the client has artificially resized the image using HTML. One recent example showed on-screen as a 300px-wide image. When I examined it, it was actually 3000px wide (approx).
The script looks through some HTML markup and, based on the sizes in the image tags, resizes the images appropriately. An example and the source are provided.
voice your opinion now!
html image size height width parse resize
Etienne Kneuss' Blog: SplFastArray to speed up your PHP arrays
by Chris Cornutt June 09, 2008 @ 12:54:04
Etienne Kneuss has posted about a new part of the Standard PHP Library that creates arrays that are up to thirty percent faster than normal methods - SplFastArray.
Antony got the idea to implement a C-like array wrapper in SPL: SplFastArray. The main advantage of that class is performance, it's indeed faster than PHP arrays. How so? No free lunch: The speedup comes from the fact that non-numeric indexes are not allowed and that the array is of fixed size.
The code sample shows the setting of the size for the array (and changing it) with a var_dump of the output result. This method is always faster than normal arrays, it just varies how much from system to system (anywhere from ten to thirty percent).
voice your opinion now!
spl splfastarray set size speed faster
DevShed: Retrieving Information on Selected Files with a PHP 5 File Uploader
by Chris Cornutt March 27, 2008 @ 09:31:04
DevShed has continued their series (here's part one) looking at the use of file uploading in your PHP scripts. They build on that foundation and add in some more useful features this time:
The initial script in the first tutorial of this series lacked some important features, such as the implementation of an effective error handling module and the ability to check the MIME type and size of the file being uploaded. In this second installment of the series, I'm going to improve the logic of the script from the first tutorial to provide it with the capacity to retrieve useful information concerning the entire file uploading process.
They look back at the previous tutorial to remind you of some of the concepts and then move on to show you how to get information about the file (like the MIME type, name and size of the uploaded file). The last page is just the full source code for the cut and pasters out there.
voice your opinion now!
tutorial php5 file upload information mime name size
Ian Selby's Blog: Uploading Large Files With PHP
by Chris Cornutt September 14, 2007 @ 13:03:54
Ian Selby, working for a startup and building a lot of code up from scratch came across a problem - the upload of pretty large files via PHP:
I have found myself in a position where I am writing scripts that may need to upload fairly large files. My scripts were timing out, and I couldn't seem to figure out why. For the unitiated, there are some standard things that you usually do to both your php.ini and in your script in this situation [...] However, it turns out there are some other php.ini config variables that you may need to look at.
The "usual suspects" list includes changing the max_upload_size value and adjusting the script timeout. The other settings he mentions, though, are things like memory_limit, post_max_size and max_input_time to help increase the default times that PHP uses on most page executions.
voice your opinion now!
upload large file phpini setting timelimit size upload large file phpini setting timelimit size
LotsOfCode.com: Tag Cloud Tutorial
by Chris Cornutt September 06, 2007 @ 08:57:00
In this tutorial on the LotsOfCode website, the author looks to help you create a feature common to several (including this one) websites out there - a tag cloud.
In this tutorial i am going to show you how to create a basic word / tag cloud using php. I am going to create a class based cloud, this is because it will be more convenient for people to adapt it on there own websites, if you don't know much about class based programming then click here to take a look at the class tutorial.
They pull the information from their "words array" (where words can be dynamically added to it) and use a percentage rating to base the CSS size for the data's span tag. The entire class listing is provided in one big chunk to make copy and paste easy.
voice your opinion now!
tag cloud tutorial dyanmic css size class method tag cloud tutorial dyanmic css size class method
|
Community Events
Don't see your event here? Let us know!
|