ID: 45462 Updated by: [EMAIL PROTECTED] Reported By: lgandras at hotmail dot com -Status: Open +Status: Bogus Bug Type: Scripting Engine problem Operating System: * PHP Version: 5.2.6 New Comment:
Thank you for taking the time to write to us, but this is not a bug. Please double-check the documentation available at http://www.php.net/manual/ and the instructions on how to report a bug at http://bugs.php.net/how-to-report.php Previous Comments: ------------------------------------------------------------------------ [2008-07-09 03:10:18] lgandras at hotmail dot com Description: ------------ When a string contains backslashs, they are shown on a way, but kept differntly on the string. This is annoying when a string needs to be parsed to know if a quote is being escaped. Reproduce code: --------------- $stringA = "\\'"; # returns \' $stringB = "\\\'"; # returns \\' $stringC = "\\\\'"; # returns \\' $stringD = "\\\\\'"; # returns \\\' # etc.. I don't have problem with it. # But! this is the way it is shown! # internally the string is kept how the programmer wrote it # how are you supposted to known with php routines # that $stringB escapes the quote and $stringC does not! # using stripslashes is not an option, # because it could delete some backslashes you want to keep. # # # I've seen other bugs, where it is told # that normal functioning of stripslashes # is to delete all the "first" slashes, # but then is not possible to parse a string # even with regular expressions to know what # a parser like mysql would understand of my # string. # # In other words, backslashes are still there, # but you can't know it! $stringB == $stringC; # devolves true, in the end is right, but not now. $stringB === $stringC; # also true (in the end), but not for mysql substr($stringB, 0, 1) === substr($stringC, 0, 1); substr($stringB, 1, 1) === substr($stringC, 1, 1); substr($stringB, 2, 1) === substr($stringC, 2, 1); # again, on the last 3 examples it returns true, # but it doesn't let me know if the quote is being escaped or not. # If questions are done, i need to parse a mysql string! # My other solution is that str_replace and/or regular # expression functions handle this issues in an adecuate way echo "B:"; echo str_replace('\\', '', $stringB); echo "<br />C:"; echo str_replace('\\', '', $stringC); Expected result: ---------------- B:\' C:' # note that this is in concordance with what the manual says Actual result: -------------- B:' C:' ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=45462&edit=1
