البرمجة

استخدام $_SERVER[‘QUERY_STRING’] في PHP

The $_SERVER['QUERY_STRING'] variable in PHP represents the query string portion of the URL that was used to access the current page. This query string typically follows the “?” character in the URL and contains key-value pairs separated by “&” symbols. For example, in the URL http://example.com/page.php?id=123&name=John, the query string is id=123&name=John.

When a user accesses a PHP script via a URL with a query string, the server parses the query string and makes the key-value pairs available to the script through $_GET superglobal array. This allows the script to access and process the parameters passed in the URL.

The $_SERVER['QUERY_STRING'] variable specifically contains the raw query string as it appears in the URL, without any parsing or modification by PHP. It can be useful when you need to access the raw query string directly for some reason, such as when you want to process it manually or log it for debugging purposes.

In summary, the $_SERVER['QUERY_STRING'] variable represents the query string part of the URL that was used to access the current page, and it provides a way to access the raw query string directly in PHP.

المزيد من المعلومات

بالطبع! ال $_SERVER['QUERY_STRING'] يعتبر جزءًا من مصفوفة $_SERVER في PHP التي تحتوي على معلومات الخادم والبيئة. ويتم استخدام $_SERVER['QUERY_STRING'] للوصول إلى السلسلة النصية للإستعلام التي تم استخدامها للوصول إلى الصفحة الحالية.

لفهم ذلك بشكل أفضل، دعنا نلقي نظرة على مثال. فرضاً أن لديك صفحة PHP تسمى page.php وترغب في الوصول إليها باستخدام الرابط التالي: http://example.com/page.php?id=123&name=John. عندما تقوم بفتح هذا الرابط، يتم استدعاء الصفحة page.php، ويصبح $_SERVER['QUERY_STRING'] يحتوي على القيمة id=123&name=John.

بمعنى آخر، يمكنك استخدام $_SERVER['QUERY_STRING'] للوصول إلى السلسلة النصية للإستعلام التي تم استخدامها للوصول إلى صفحتك في PHP.

مقالات ذات صلة

زر الذهاب إلى الأعلى
إغلاق

أنت تستخدم إضافة Adblock

يرجى تعطيل مانع الإعلانات حيث أن موقعنا غير مزعج ولا بأس من عرض الأعلانات لك فهي تعتبر كمصدر دخل لنا و دعم مقدم منك لنا لنستمر في تقديم المحتوى المناسب و المفيد لك فلا تبخل بدعمنا عزيزي الزائر