News Feed
Jobs Feed
Sections




News Archive
feed this:

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

Evert Pot's Blog:
iconv_substr vs mbstring_substr
September 30, 2011 @ 11:03:20

Evert Pot came across an interesting performance issue as he was working through an application that needed to do some string substitutions - the difference between iconv_substr, mb_substr and substr.

While working on an application I ran across a huge bottleneck which I isolated down all the way to the use of the iconv_substr function. If you ever wonder which is better to use, [the benchmark code in the post[ should help your decision.

His results changed quite a bit from machine to machine (and OS/platform to OS/platform) but one statistic stood out on them all - the iconv_substr was slower than mb_substr method....by a lot in one case (about 2100000% slower).

0 comments voice your opinion now!
benchmark iconvsubstr mbstringsubstr substr substring


NETTUTS.com:
How to Create Blog Excerpts with PHP
July 23, 2010 @ 09:11:18

On NETTUTS.com today there's a tutorial (a screencast) that'll show you how to create excerpts for the posts in your blog. Their method could be applied to just about any PHP-based blog software out there since it uses base PHP functions and MySQL features.

Ever visited a blog, and noticed that each posting's overview only contained a hundred characters or so, which is then followed by '''? Ever wondered how to do that yourself? It's not quite as easy as you might think. What if character number 100 occurs in the middle of a word? Do you want to display half of a word on the page? Of course not. In this video tutorial, I'll show you how to compensate for this, as well as a host of other neat little things, like working with MySQL's LEFT() function, using PHP's strrpos, and substr, creating the beginning's of an actual blog, and more.

They show you how to use the MySQL LEFT() function, strrpos and substr to make creating these summary blocks of text simple.

0 comments voice your opinion now!
blog excerpt tutorial screencast mysql strrpos substr


Hasin Hayder's Blog:
Web scrapping in a smart way, making a "Today in History" object in PHP
April 29, 2008 @ 10:27:41

Hasin Hayder has written up a quick tutorial for his blog that shows how to create your own "Today in History" page with details from Scopesys pulled with a little web scraping.

There are thousands of services available on web who are presenting interesting as well as education information which you can really integrate in your web page or make a nice widget and let others use them seamlessly with their content delivery platforms. In this article I am going to show you how you can make a nice Today-in-History widget with the help of the data provided in Scopesys.

He wisely recommends that you check one thing first about the content you're grabbing - the copyright it carries with it. This could get you into big trouble down the line depending on whose content it is. The actual script is pretty simple - he defines some constants as markers for where things start and stop in the HTML and then uses strpos to get the locations for his substr call to grab the segments.

0 comments voice your opinion now!
todayinhistory widget copyright scopesys constant define substr strpos


Christian Stocker's Blog:
Calling PHP function from XSLT vs. native XSLT functions benchmark
March 27, 2006 @ 06:55:47

One of the more underused thechnologies to come along these days is XSLT - that powerful langauge to style XML documents in a simple, "more correct" kind of way (seperation of data and layout). Most languages have support for this combination, including PHP - but what's the best way to combine PHP and XSLT? Christian Stocker took a look in this new post on the Bitflux blog.

After Rob's idea from yesterday about using XMLReader within XSLT I was wondering, how much of a slowdown calling PHP functions from XSLT is.

I wrote 4 different XSLT templates, which do a simple substring. One with the xslt function "substring", one with just calling the native PHP function "substr" and one with calling a user-defined function (which is also just calling "substr"). I called this 100 times (with one of those great recursive self-calling xslt-templates) and did call the "transformToXML" function a 100 times for each stylesheet. This means, we called the function 10'000 times for each benchmark run.

His bases the results off of a sample with no function call at all and, but running it through 100 times, came up with results that weren't all that surprising. In order of speed, the ranking (shortest time first) was: no call, xslt only, php native, and php userland. Using the PHP functions from inside of XSLT made the test quite a bit slower, but, as he notes, most users won't be running recursions of 100 each time they run a script.

1 comment voice your opinion now!
XSLT native functions user-defined substring substr XSLT native functions user-defined substring substr



Community Events











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


unittest symfony2 composer example opinion component code podcast introduction framework hhvm application language release install facebook hack security package series

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