News Feed
Sections




News Archive
feed this:

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

Ilia Alshanetsky's Blog:
PHP's Output Buffering
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.

0 comments voice your opinion now!
output buffer increase patch custom size


Kevin Schroeder's Blog:
fatal The remote end hung up unexpectedly
November 04, 2011 @ 12:55:28

Kevin Schroeder has a quick tip for anyone using phpcloud.com and having trouble with git and "remote end hung up" error messages.

If you are using phpcloud.com and are experiencing errors with git [...] and you are trying to push large files (not sure what is defined as "large") you may need to change some git settings.

He points out two settings - one for Windows and the other for Linux - that increase the buffer size to handle larger files that might be included in your repository.

0 comments voice your opinion now!
phpcloud git problem large file buffer size


SitePoint PHP Blog:
Speed Up Your Website with PHP Buffer Flushing
October 29, 2010 @ 08:34:18

New from the SitePoint blog, there's an article from Craig Buckler about using buffer flushing to increase the load times of your applications and websites.

Output buffering makes this process quicker and more efficient. The buffer is essentially a big memory-resident string. When text is output, it's appended to the buffer rather than returned to the browser immediately. The buffer is then "flushed", i.e. its contents are transmitted and the string is reset pending further output.

He notes the instances where the buffer would be flushed - end of page, exceeds number of bytes allowed or a manual flush is called - and code snippet example of a simple flushing setup. He also asks for some feedback on this method, so be sure to look at the comments for more thoughts from the community.

1 comment voice your opinion now!
buffer flush output speed optimize


Gonzalo Ayuso's Blog:
Live video streaming with PHP
September 20, 2010 @ 08:46:06

In a new post to his blog today Gonzalo Ayuso talks about video streaming and PHP. Well, okay, not so much using PHP for playing the video, more for the security and streaming around the streaming feeds.

For example we want to show videos only to registered users based on our authentication system. Imagine we're using sessions for validate users. That's means we cannot put the media in a public folder and point our media player to those files. We can obfuscate the file name but it'll remain public. In this small tutorial We're going to see how to implement it with PHP.

Since the video stream he wants to deal with is a live one (and not a single video file that can be read all at once) he shows how to use the output buffering functions in PHP to output small chunks of the data at a time with the correct headers attached.

0 comments voice your opinion now!
video stream live feed tutorial output buffer


Brian Moon's Blog:
ob_start and HTTP headers
February 01, 2010 @ 14:38:27

Brian Moon has a new post to his blog today looking at something it's common for web applications to use, ob_start, and what about HTTP headers makes it work to prevent the infamous "headers already sent" message.

HTTP is the communication protocol that happens between your web server and the user's browser. Without too much detail, this is broken into two pieces of data: headers and the body. The body is the HTML you send. But, before the body is sent, the HTTP headers are sent.

He includes a sample raw HTTP response for a page and how the ob_start function works to buffer the output of the resulting page to save the header information until the buffer is echoed or cleaned out. There is a down side he mentions, though - there's no partial buffering built in so it's an all or nothing short.

0 comments voice your opinion now!
obstart http header buffer


Kae Verens' Blog:
Serving files through a script
January 14, 2009 @ 09:37:55

Kae Verens has posted a quick tutorial about serving up files by routing them through a "fetch" script, pulling their contents in one side and back out the other.

One thing I need to do while building the multi-user version of webme is to convert it so file references such as /f/photos/an_image.jpg get transparently converted so they serve correctly, even though the actual file may be located somewhere entirely else.

There's two steps involved - rewriting the URL request for the types of files you'd like to pull through the script (using some mod_rewrite magic in Apache) and make the script to do the actual work. Source for that is included too. Not only can something like this help you keep things organized but it also allows for extra security if you need to store the files outside of the webserver's document root.

0 comments voice your opinion now!
serve file script modrewrite output buffer readfile


DevShed:
Output Buffering
September 03, 2008 @ 08:48:16

This new tutorial from DevShed introduces something that could make a pretty profound impact on your application if used correctly - output buffering.

Output control (or output buffering) allows you to write and execute your scripts normally but send data to the web browser at selected times. The main benefit of this system is that you can call the header(), setcookie() and session_start() functions at any place in your scripts without having to worry about the "headers already sent" error message.

They start with the basics - the functions and what they do - then move on to an example, a login form, that uses the buffering to capture errors and html to be flushed and echoed at the end.

0 comments voice your opinion now!
output buffer tutorial login form example


Internet Super Hero Blog:
mysqlnd saves 40% memory, finally (new tuning options)!
August 27, 2007 @ 12:11:00

Even more good news for mysqlnd users out there - according to this new post on the Internet Super Hero blog, some of the tuning options it enables can help you save 40% of the memory you were using before.

mysqlnd saves memory. It consumes half as much memory as libmysql. This is what we have been convinced of. This is what we taught you. Then I tried to test it and made Andrey get nervous for a few hours' Meanwhile he is fine again and we can announce: mysqlnd saves memory, not only in theory, we tested it - we can proof it, can we?

The proof comes in the form of a few "tricks" and some of the settings that the software can use to optimize buffer sizes. Benchmarks (and the code to run them) are also included to show what the differences are between mysqlnd and libmysql.

0 comments voice your opinion now!
mysqnd save memory tuning option buffer benchmarks mysqnd save memory tuning option buffer benchmarks


Secunia:
Cisco Products PHP "htmlentities()" and "htmlspecialchars()" Buffer Overflows
April 26, 2007 @ 07:55:00

Cicso product users should check out this latest issue Secunia has released today - a problem with the htmlentities and htmlspecialchars functions that can lead to buffer overflows.

The vulnerabilities are caused due to boundary errors within the "htmlentities()" and "htmlspecialchars()" functions. If a PHP application uses these functions to process user-supplied input, this can be exploited to cause a heap-based buffer overflow by passing specially crafted data to the affected application.

Successful exploitation may allow execution of arbitrary code, but requires that the UTF-8 character set is selected.

Products affected include the Network Analysis Modules (NAM) for Cisco 6500 switch, Cisco 7600 router/Branch Routers and the CiscoWorks Wireless LAN Solution Engine (WLSE) and CiscoWorks Wireless LAN Solution (among others, check out the advisory for a more complete list).

There are some patches that have been released to correct this issue (like the one for the Cisco Unified Application Environment) but others are still yet to come. They recommend limiting access to only trusted IPs and devices only to reduce the risk of the problem being exploited.

1 comment voice your opinion now!
cisco buffer overflow htmlspecialchars htmlentities advisory cisco buffer overflow htmlspecialchars htmlentities advisory


Stoyan Stefanov's Blog:
Performance tunning with PEARDB
January 17, 2007 @ 09:35:00

Stoyan Stefanov has posted some of his tips to his blog today. Specifically, they deal with the PEAR::DB class, demonstrating some of the optimization of the package he's discovered in his coding experience.

If you use PEAR::MDB2, you can set a custom debug handler and collect all the queries you execute for debugging and performance tunning purposes, as shown before. But what if you're using PEAR::DB? Well, since PEAR::DB doesn't allow you such a functionality out of the box, you can hack it a bit to get similar results.

He creates a simple app to help with the illustration - a number of select queries to grab zipcode information from the database. As it stands, the PEAR::DB package doesn't handle the debugging well, so he adds in a few more lines to buffer the connection and some reporting code to check the resulting output (as well as some of his sample reports).

0 comments voice your opinion now!
pear package peardb performance tuning buffer connection reporting pear package peardb performance tuning buffer connection reporting



Community Events





Don't see your event here?
Let us know!


zendserver language tips community introduction api package update symfony podcast library laravel interview opinion release framework list install series deployment

All content copyright, 2014 PHPDeveloper.org :: info@phpdeveloper.org - Powered by the Solar PHP Framework