Edit report at http://bugs.php.net/bug.php?id=52031&edit=1
ID: 52031 Updated by: degeb...@php.net Reported by: d dot reade at ReadesGroupServices dot com Summary: Passing "0" as a parameter through a custom method -Status: Open +Status: Bogus Type: Bug Package: Unknown/Other Function Operating System: CentOS 5.5 PHP Version: 5.3.2 New Comment: Sorry, but your problem does not imply a bug in PHP itself. For a list of more appropriate places to ask for help using PHP, please visit http://www.php.net/support.php as this bug system is not the appropriate forum for asking support questions. Due to the volume of reports we can not explain in detail here why your report is not a bug. The support channels will be able to provide an explanation for you. Thank you for your interest in PHP. See: http://php.net/manual/en/language.types.type-juggling.php Previous Comments: ------------------------------------------------------------------------ [2010-06-09 14:41:32] d dot reade at ReadesGroupServices dot com Description: ------------ Sorry but I didn't know how to best word the summary. I have a custom method with an if statement inside. If the parameter passed through matches "Test", a string is echo'ed. However if I pass "0" through as the parameter, PHP thinks this is "Test" and echoes the string. Passing a blank parameter through, i.e. "", does not have the same effect as "0". Inserting "if (empty($str))" before the if statement in the example works as expected, catches the "0" parameter and I get the expected result. However without this, I get the actual result. All plugins have been disabled and Apache restarted. Test script: --------------- <?php function testMethod($str = 0) { if ($str == 'Test') { echo 'Test String!<br>'; } } testMethod('Test'); testMethod(0); testMethod(); testMethod(1); testMethod('Something'); ?> Expected result: ---------------- Test String! Actual result: -------------- Test String! Test String! Test String! ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/bug.php?id=52031&edit=1