![]() |
Bug in PHP?/Unknown output?
Hi,
This is a simple function for throwing error in a MySQL class(Private)... PHP Code:
Output: yyy{|mososntiWi~{sklu]~/5.2.8] [mysql.php] [XXXXX] [219] [ OS: Redhat Linux/Windows Xp SP2 PHP: 4/5 Server: Apache 2 |
Oh where to start.
Now onto the "bug", which really isn't one. The root of the problem is that you use the "bitwise or" ( |) operator which is playing around with the bits in your strings. It is basically taking the string before the | and "or"ing that with the string after it. The output will vary but given the following:Code:
$_SERVER['SERVER_SOFTWARE'] = 'my server software';Code:
'[my server software] [bug.php] [bug] [3] [' | '-9999ThisIsNotAVariable].'Code:
}y9{uzw{sovuwarm}bg}o.php] [bug] [3] [Code:
yyy{|mososntiWo{yibmo}ssl/2.2.9 OpenSSL/0.9.7l DAV/2 PHP/5.3.0RC2-dev mod_perl/2.0.2 Perl/v5.8.8] [bug.php] [fail] [9] [ |
But i thinking this is a bug...
|
It is not.
|
Oh and I think you need to manage your code better, that's all jumbled into one place. :S
|
What is your intention? To attempt to break PHP? I think PHP will break you before you break PHP.
|
Quote:
In programming, before you go yelling "bug!" you should know how it happened, why its a bug, and how it could be fixed. Otherwise you do not understand the issue and are therefore not qualified to assess if it is indeed a bug. At this point you simply do not understand the nature of the code, which may be because it one of the messiest pieces of code I've seen in a very long time. I can hardly read that..... The reason you are getting these weird characters is because you are making bad conversions to a string. Since all data boils down to 0's and 1's, all data can be applied to all other data; you just won't get anything nice looking. I see you outputting the following: 1. Strings 2. Something typecasted to a string 3. Integers 4. Booleans (which are integers) 5. Strings with integer operations applied to them With all that meshed into one output statement, I find it amazing you are surprised at the unreadable output. |
Quote:
http://bugs.php.net/bug.php?id=46156 As for the replies; Salathe, __FILE__ etc. is actually not constants, they are tokens and replaced at compile time: PHP Code:
Code:
T_OPEN_TAGBut for the "bug" itself, it comes from the bitwise operator and how ASCII characters are used in those operations. The expression you write: PHP Code:
PHP Code:
|
Quote:
|
Quote:
|
Quote:
For example: Code:
Apac = 01000001 01110000 01100001 01100011 |
| All times are GMT. The time now is 07:04 PM. |
Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0