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

Joseph Scott's Blog:
Why PHP Strings Equal Zero
Mar 15, 2012 @ 14:47:49

Joseph Scott has a new post to his blog looking at "why PHP strings equal zero" - that when you use the "==" operator on a string to compare to zero, it's true.

The issue of PHP strings equaling zero has come up a few times recently. [...] Running that will display Equals zero!, which at first glance probably doesn’t make much sense. So what is going on here?

He gets into the specifics of what's happening - a bit of type jugging, less strict comparison since it's the "==" versus "===" and how the PHP manual talks about strings being converted to numbers.

While I still think it is odd that the string gets cast as an integer instead of the other way around, I don’t think this is a big deal. I can’t recall a single time where I’ve ever run into this issue in a PHP app. I’ve only seen it come up in contrived examples like the ones above.
tagged: string equal zero type juggling conversion

Link:

Ant Phillips' Blog:
Singletons, BIRT, Theads and PHP
Feb 18, 2009 @ 18:55:47

In doing some work with Zero (PHP in Java) and the Eclipse Business Intelligence and Reporting Tools project, Ant Phillips had some troubles with multithreaded PHP processes and wanting them all to use the same BIRT instance insted of spawning their own.

The problem is that BIRT needs to be started once, and only once, in any given process. Once it has been started up, then it is plain sailing to load reports and render them to HTML. The BIRT runtime should be kept around until the process shuts down.

Two problems came up with this approach - if each PHP process makes its own BIRT process any settings/current data will be wiped out and the BIRT instance would go away whenever the PHP script finishes. He found something that solves both of these problems - the Zero Global Context. Its a "storage area" that can contain just about anything. He used it to store the BIRT runtime until its told to finish and die off.

tagged: birt java zero multithread singleton process global context

Link:

An Phillips' Blog:
COM/.NET Interop in Zero PHP
Jan 29, 2009 @ 21:03:25

Ant Phillips looks a bit at some interoperability between the PHP and Project Zero when to comes to using the COM/.NET extension.

Zero doesn't currently support the COM/.NET extension in PHP. No matter though, there is a handy open source project called JACOB that bridges between Java and COM/.NET. In fact, there is an easier way to do this using a Groovy library called Scriptom. This is really just a friendly wrapper around JACOB to provide a better syntax for calling methods and accessing properties.

He also includes a quick introduction and howto on getting the functionality up and working in a Windows environment - download, add the JAR to your path, edit your php.ini and copy and paste some example code in to see it in action.

tagged: com net interoperability zero extension jacob scriptom

Link:

Felix Geisendorfer's Blog:
False == 0, or not?
Aug 14, 2007 @ 13:45:00

Felix Geisendorfer has come across something interesting in his coding - an issue where false might not be false in the right situation.

So far I've always thought false would evaluate to 0 when used in a computational context. Turns out that this isn't always the case.

His code example tries to check is a false value is greater than or equal to a negative number. The result, however (despite the thinking that false is a zero value) turns out to be false.

I randomly stumbled upon this when arguing with Mariano today if setting Model::recursive to 'false' has the same effect as setting it to '-1'. Turns out that cake uses a statement like this: if ($recursive > -1) in the core which in turn makes -1 and false do exactly the same thing.
tagged: false zero evaluate compare negative false zero evaluate compare negative

Link:

Felix Geisendorfer's Blog:
False == 0, or not?
Aug 14, 2007 @ 13:45:00

Felix Geisendorfer has come across something interesting in his coding - an issue where false might not be false in the right situation.

So far I've always thought false would evaluate to 0 when used in a computational context. Turns out that this isn't always the case.

His code example tries to check is a false value is greater than or equal to a negative number. The result, however (despite the thinking that false is a zero value) turns out to be false.

I randomly stumbled upon this when arguing with Mariano today if setting Model::recursive to 'false' has the same effect as setting it to '-1'. Turns out that cake uses a statement like this: if ($recursive > -1) in the core which in turn makes -1 and false do exactly the same thing.
tagged: false zero evaluate compare negative false zero evaluate compare negative

Link:

Mike Lively's Blog:
81.4 is evil
Jan 04, 2007 @ 14:39:00

On his blog, Mike Lively has a little reminder for developers out there about working with floating point numbers in your applications, specifically their accuracy.

I know many of you all know pretty well that floating point precision and computers don't play nicely with each other. [...] I was working with a piece of code today at the office that was throwing an error saying two values weren't zeroing out when they clearly should have been.

In his code he shows the simple bit that he was using to evaluate if the result of subtraction would come to a certain value. In the comments, others share similar experiences and one even recommends another option to make things a bit more accurate - the bcmath library.

tagged: floating point accuracy zero value floating point accuracy zero value

Link:

Mike Lively's Blog:
81.4 is evil
Jan 04, 2007 @ 14:39:00

On his blog, Mike Lively has a little reminder for developers out there about working with floating point numbers in your applications, specifically their accuracy.

I know many of you all know pretty well that floating point precision and computers don't play nicely with each other. [...] I was working with a piece of code today at the office that was throwing an error saying two values weren't zeroing out when they clearly should have been.

In his code he shows the simple bit that he was using to evaluate if the result of subtraction would come to a certain value. In the comments, others share similar experiences and one even recommends another option to make things a bit more accurate - the bcmath library.

tagged: floating point accuracy zero value floating point accuracy zero value

Link:

Davey Shafik's Blog:
php|tek Days 0 & 1
Apr 26, 2006 @ 21:18:33

Davey Shafik has already gotten some of his experiences down in blog post form from the php|tek conference today, actually starting with the day previous in his Day 0 and Day 1 posts.

In the Day 0 post he just mentions arriving at the conference and getting things ready, but Day 1 sees him giving his "Future Deployment of PHP Applications" talk and his upcoming "Migration to PHP 5.1".

He also mentions videoing the presentation from today ("Deployment" talk) and is hoping to get a Flash video of the presentation up for all to see post-conference (a great idea for non-attendees).

tagged: phptek conference blog days zero one talks video flash movie phptek conference blog days zero one talks video flash movie

Link:

Davey Shafik's Blog:
php|tek Days 0 & 1
Apr 26, 2006 @ 21:18:33

Davey Shafik has already gotten some of his experiences down in blog post form from the php|tek conference today, actually starting with the day previous in his Day 0 and Day 1 posts.

In the Day 0 post he just mentions arriving at the conference and getting things ready, but Day 1 sees him giving his "Future Deployment of PHP Applications" talk and his upcoming "Migration to PHP 5.1".

He also mentions videoing the presentation from today ("Deployment" talk) and is hoping to get a Flash video of the presentation up for all to see post-conference (a great idea for non-attendees).

tagged: phptek conference blog days zero one talks video flash movie phptek conference blog days zero one talks video flash movie

Link:


Trending Topics: