 | News Feed |
 | Jobs Feed |
Sections
|
| feed this: |  |
Stoimen Popov's Blog: PHP Performance Bitwise Division
by Chris Cornutt January 06, 2012 @ 09:26:38
Stoimen Popov has a new post to his blog today comparing the performance of bitwise division versus the normal "/" division operator.
Recently I wrote about binary search and then I said that in some languages, like PHP, bitwise division by two is not faster than the typical "/" operator. However I decided to make some experiments and here are the results.
According to his results using the bitwise method is slightly faster, but you'd only really notice it when working with large sets of data (like his example using 10,000,000). The code to run his benchmarks is included in the post.
voice your opinion now!
bitwise division benchmark compare operator
Sameer Borate's Blog: Disabling the silence @-operator in PHP
by Chris Cornutt July 06, 2010 @ 08:42:22
As Sameer Borate points out in his latest post to his blog, there's a way to disable that pesky suppression operator (@) in your PHP installation thanks to the scream extension.
PHP supports one error control operator: the at sign (@). When prepended to an expression any error generated by that expression will be ignored. It can also be useful for hiding errors generated by various functions. [...] Although quite useful at some times, using the @-operator can have some annoying side effects.
He shows you how to install the extension on a stock Ubuntu platform (including the PHP packages) and how use the feature in your application by means of a call to ini_set (or, of course, setting it in your php.ini file).
voice your opinion now!
disable supress operator scream extension
Johannes Schluter's Blog: Class posing and overloading the "new" operator
by Chris Cornutt January 07, 2010 @ 10:24:16
In this recent post to his blog Johannes Schluter talks about a method he's suggested for testing objects in unit tests - overriding the "new" operator to replace specific classes with mocks.
Two years ago at some conference I had a conversation with Sebastian about the need for a way to overload the new operator in PHP so, probably, bad designed code can be tested more easily by replacing specific classes with mocks. [...] Sebastian then pushed the code as part of a new test_helpers extension with some documentation to github and I fixed some bugs in it. The aim of the extension is to collect functionality which might be beneficial for phpUnit and other test scenarios but which should never reach a production environment.
He includes some sample code to show it in action - defining the mock class, using the set_new_overload function to define it as what should be called when the "new" operator is used and a dump of the result.
voice your opinion now!
overload new operator mock unittest
ThinkPHP Blog: Silence of the LAMPs
by Chris Cornutt September 16, 2009 @ 09:13:40
In a recent post to the ThinkPHP blog Martin Brotzeller looks at a PHP operator that developers should just not use anymore - the suppression operator (@).
The silence operator exists to give programmers an easy way to suppress messages when a command might fail and the code checks for success itself (i.e. in those cases that raise errors instead of throwing exceptions).
He points out a popular use (like putting it on an fopen to prevent it from throwing an E_WARNING) but notes that this could cause trouble if the code is several layers deep and seems to fail silently. He gives en example of the Zend_Loader component of the Zend Framework and how, if the suppression operator was used, errors with an include failed without so much as a blip in the error log. While it seems handy, the suppression operator can cause more harm than good in the long run.
voice your opinion now!
suppression operator avoid
Mark van der Velden's Blog: PHP Quiz part 2
by Chris Cornutt May 14, 2009 @ 12:05:22
Mark van der Velden has posted another PHP quiz you can used to test your knowledge of the language:
A short quiz this time, but that doesn't make it less fun. Do you know the answer to all of them? Get a cup of coffee and kill 10 minutes with round two... As always, think of the answer before you execute the code or look it up. You can find round one here.
This one has questions on arrays, ArrayAccess, references, operator precedence and nesting structures. There's no answer key, so you'll just have to test it out if you want to see the answer.
voice your opinion now!
operator nesting reference array quiz
PHPBuilder.com: Loops & Decisions in PHP - The ABC's of PHP Part 8
by Chris Cornutt May 07, 2009 @ 10:26:34
PHPBuilder.com has posted the eighth part of their introductory "ABCs of PHP" series today. This time the focus is on looping and decision functionality (like if/while/for/etc).
n any given computer language (PHP is no exception) there has to be a way to allow the running code to decide between doing 2 different things. If there wasn't then software would not be able to adapt based on operating conditions, or it wouldn't be able to decide between two different users.
They look at using: if statements and operators, for loops and while loops. When they look at the operators, they talk about the differences between equals/not equals, grater than/less than and two of the boolean operators - AND and OR.
voice your opinion now!
loop decision if while for operator tutorial introduction beginner
Johannes Schluter's Blog: Scream!
by Chris Cornutt February 27, 2009 @ 11:14:50
After being tasked with some code that was filled with the suppression character (@) all over, Johannes Schluter decided to take matters into his own hands and write an extension to disable it.
That's annoying. So I wrote a simple extension disabling this operator. That helped. I then proposed that extension to pecl, while doing that I found out that Gopal has written a similar extension before. After short discussions we added that extension, using the name scream to pecl and released the extension there.
Documentation for the extension has already been added to the PHP manual for the "Break the Silence" operator. By enabling the setting (either in your php.ini or via an ini_set) turning on "scream_enabled", any use of the suppression operator (@) will be nulled out and all according error messages will be displayed.
voice your opinion now!
screan suppression operator pecl extension remove phpini
Debuggable Blog: Supressing Errors in PHP
by Chris Cornutt January 30, 2009 @ 11:14:58
Felix Geisendorfer has posted two new items to the Debuggable blog looking at suppressing errors in your applications - and no, that doesn't mean using the @ operator either.
As of late I am getting sick of some best practices I have taught myself. Never using the @-error suppressing operator quickly moving to the top of the list. Before you start crying out loud (I know you will), let me say this: I do not mean to encourage anybody to use the @-operator. Applying the practice herein introduced may result in permanent damage to your coding habits and could serve as a gateway behavior to writing shitty code.
He gives an example in the first post of a place where he failed to properly check to ensure an element existed before checking a element of it. The second post provides an interesting solution to the same problem - using empty on the element/subelement to check its existence.
voice your opinion now!
suppress error empty isset check exist shutup operator symbol
Derick Rethans' Blog: Five reasons why the shut-op operator (@) should be avoided
by Chris Cornutt January 05, 2009 @ 12:09:37
Derick Rethans has posted just a few of the reasons why the "shut-up operator" (the @ symbol) should be avoided at all costs in your PHP applications.
The @-operator is often used to silence errors in noisy PHP functions'"functions that generate warnings that can not be easily prevented. [...] In those cases, there is no way how to check up-front whether the function call will not issue a warning when being called.
There are side effects to using the operator, however, including hiding legitimate errors and making debugging that much more difficult. To back up his point, he includes four other reasons to avoid the operator's use (besides the debugging issues):
- It's slow (part 1)
- It's slow (part 2)
- It's slow (part 3: It generates crappier code)
- Apfelstrudels were harmed (related to the strudel_token in the C code for the operator)
voice your opinion now!
shutup operator atsign avoid reason slow debugging error hide
|
Community Events
Don't see your event here? Let us know!
|