-
Notifications
You must be signed in to change notification settings - Fork 3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Parse_str(string,array) semantics #1146
Comments
i watched the implementation in hhvm: |
You should build HHVM from source using master HEAD, because this issue was fixed 22 days ago in #1063. |
very thx, @javer |
1)resolved this problem with new version. $name is undefined in hhvm. |
It is the same as in PHP. Look at PHP manual http://php.net/manual/en/function.parse-str.php:
|
@javer ,I have fixed @zhangmuhua 's problem.
I will pull request hiphop-php master.^_^ |
@huzhiguang, not sure if it should be fixed, because PHP and HHVM results is the same. test.php: <?php
error_reporting(E_ALL);
parse_str("id=23&name=John%20Adams", $a);
print_r($a);
echo $name . "\n"; PHP: $ php -n test.php
Array
(
[id] => 23
[name] => John Adams
)
Notice: Undefined variable: name in test.php on line 5 HHVM: $ hhvm test.php
Array
(
[id] => 23
[name] => John Adams
)
HipHop Notice: Undefined variable: name in test.php on line 5 In your patch you can overwrite previously defined variables, check this test: <?php
$name = 'Smith';
parse_str("id=23&name=John%20Adams", $a);
echo $name . "\n"; And it will be undocumented behavior because according to PHP manual when second parameter is given no variables should be extracted. |
I have fixed this problem, you can try it,do you see any other questions? fixed code as follow:
|
@huzhiguang, compare output of this script on PHP and your patched HHVM: <?php
parse_str("id=23&name=John%20Adams", $a);
var_dump(isset($name)); PHP Output:
As I said before, this is because no variables should be extracted when second parameter of parse_str is given. See https://github.com/php/php-src/blob/master/ext/standard/string.c#L4454-4460 for details. |
Thanks @javer. @zhangmuhua, we're not going to make this work when Zend doesn't -- I suggest you take it up with them if you want the behavior of the language to be changed in 5.6 or 5.7, then we'll consider fixing it. |
ok,@javer,I have looked at the zend implementation logic, arrayArg !=NULL parse variable don't use zend_rebuild_symbol_table,so variable do not exist,I have understanded.thanks,you provide way is true,although the notice problems. |
i use function parse_str to parse url, but fail with hhvm.
code as follows:
1
php interpreter print as follows:
23
John Adams
but hhvm interpreter print as follows:
HipHop Notice: Undefined variable: id in */test/test_parse_str.php on line 4
HipHop Notice: Undefined variable: name in */test/test_parse_str.php on line 6
who can help me? how can i use this function in hhvm?
The text was updated successfully, but these errors were encountered: