|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2010-06-09 14:51 UTC] degeberg@php.net
-Status: Open
+Status: Bogus
[2010-06-09 14:51 UTC] degeberg@php.net
[2010-06-09 14:57 UTC] d dot reade at ReadesGroupServices dot com
[2010-06-09 15:14 UTC] degeberg@php.net
[2010-06-09 15:16 UTC] d dot reade at ReadesGroupServices dot com
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Mon Nov 24 17:00:01 2025 UTC |
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!