|
użytkowników online: 26
|
OPINIE UŻYTKOWNIKÓW
|
W takich dniach, jak ten, nie żałuję, że wykupiłem abonament. Korzystam z porad na tych stronach nawet kilkanaście razy w tygodniu i dzięki nim prace nad stronami dla klientów idą mi o wiele szybciej, a strony wyglądają bardziej profesjonalnie. Nie wiem, jak mogłem wcześniej pracować bez dostępu do porad w tym serwisie!
Wojciech Miszkiewicz
|
|
PODRĘCZNIK PHP 5.x, 4.x, 3.x - częściowo spolszczony / źródło: www.php.net
[Spis]
[A]
[B]
[C]
[D]
[E]
[F]
[G]
[H]
[I]
[J]
[K]
[L]
[M]
[N]
[O]
[P]
[Q]
[R]
[S]
[T]
[U]
[V]
[X]
[W]
[Z]
parse_str (PHP 3, PHP 4, PHP 5) parse_str -- Parses the string into variables Descriptionvoid parse_str ( string str [, array &arr] )
Parses str as if it were the query string
passed via a URL and sets variables in the current scope. If
the second parameter arr is present,
variables are stored in this variable as array elements instead.
Notatka:
Support for the optional second parameter was added in PHP 4.0.3.
Notatka:
The magic_quotes_gpc setting
affects the output of this function, as parse_str() uses
the same mechanism that PHP uses to populate the $_GET,
$_POST, etc. variables.
Przykład 1. Using parse_str() |
<?php
$str = "first=value&arr[]=foo+bar&arr[]=baz";
parse_str($str);
echo $first; echo $arr[0]; echo $arr[1]; parse_str($str, $output);
echo $output['first']; echo $output['arr'][0]; echo $output['arr'][1]; ?>
|
|
See also parse_url(), pathinfo(),
get_magic_quotes_gpc(), and urldecode().
User Contributed Notesavi at amarcus dot com
04-Sep-2005 03:32
If you are trying to preserve a complex array, the function serialize might be better than http_build_query or other methods of making a query string.
ET
01-Sep-2005 12:14
In reply to what kerosuppi posted:
[quote]This does not work as expected.[/quote]
No, it works exactly as expected.
The call <?php parse_str($this->query_string);?> "sets variables in the current scope" (just like said in the manual).
You are using this call in the constructor. Once the constructor is finished, the scope of this function has ended so it's logical that you can't access the variables anymore.
Your workaround though is a good one.
Hope this helps,
ET
Tore Bj
|