Super Global Variables in PHP

Super Global Variables in PHP - Hindi

Super Global Variables in PHP – Server Configuration व Request Message Information जैसे कि Cookies, Form Parameters, Web Browser के Address Bar में Specified URL या किसी Link पर Click करने पर Generate होने वाले Request Message आदि को PHP Script द्वारा तीन अलग तरीकों से Access किया जा सकता है। इन सभी प्रकार के Accessible Information को एक शब्द EGPCS द्वारा Refer किया जाता है, जो कि Environment, GET, POST, CookiesServer का Short Form है।

PHP हमें 6 ऐसे Unique Global Arrays Provide करता है, जिनका प्रयोग करके हम Request Message में आने वाली विभिन्न प्रकार की Information को Access कर सकते हैं। ये Arrays निम्नानुसार हैं:

$COOKIE Global Array

ये एक Associative Array होता है जो कि Current Script में HTTP Cookies द्वारा Pass होता है। इस Array में Web Browser द्वारा Request Message के साथ Pass की जाने वाली Cookie Values होती हैं जबकि Array के Key के रूप में Cookies के नाम होते हैं।

$_GET Global Array

ये भी एक Associative Array होता है जो कि Current Script में GET Method का प्रयोग करते हुए GET Request में Pass किए गए Form Parameters होते हैं। इस Associative Array में Form के Parameters के नाम Array की Key के रूप में होते हैं जबकि Form के Parameters की Value, Array की Key के साथ Associative Values होती हैं।

GET Variables urldecode() Function का प्रयोग करते हुए Decoded रूप में Request को Web Server पर Send करते हैं।

$_POST Global Array

ये भी एक Associative Array होता है जो कि Current Script में POST Method का प्रयोग करते हुए POST Request में Pass किए गए Form Parameters होते हैं। इस Associative Array में Form के Parameters के नाम Array की Key के रूप में होते हैं जबकि Form के Parameters की Value, Array की Key के साथ Associative Values होती हैं।

$_FILES Global Array

ये भी एक Associative Array होता है जो कि Current Script में HTTP POST Method का प्रयोग करते हुए Web Server पर Upload की गई Files की Information को Hold करता है।

$_ENV Global Array

ये भी एक Associative Array होता है जो Current Script के सभी Environment Variables की Values को Hold करता है। इस Array की Keys के रूप में विभिन्न Environment Variables के नाम होते हैं।

$_SERVER Global Array

ये भी एक Associative Array होता है जिसमें Web Server से संबंधित विभिन्न प्रकार की बहुत सारी जानकारियां होती हैं। इसके विषय में हम अगले Section में Detail से जानेंगे।

उपरोक्त सभी Global Variables वास्तव में Super Global Variables हैं क्योंकि ये न केवल Current Script में Directly Access होने के लिए Available रहते हैं, बल्कि ये किसी Function में भी Globally Available रहते हैं।

PHP $_REQUEST नाम का एक और Global Array Create करता है जो कि एक Associative Array ही होता है। लेकिन इसमें Value के रूप में $_GET, $_POST$_COOKIE तीनों Arrays के सभी Elements Combined रूप में एक ही Array में Stored होते हैं।

इसलिए अलग-अलग परिस्थितियों में जरूरत के आधार पर $_GET, $_POST व $_COOKIE तीनों को अलग-अलग उपयोग में लेने के बजाय केवल $_REQUEST Global Variable को Use करके भी अपनी सभी जरूरतों को पूरा कर सकते हैं।

PHP $PHP_SELF नाम का भी एक Variable Create करता है, जो कि Current PHP Script का नाम Value के रूप में Hold करता है। ये नाम Document Root से Relative होता है। इस Value को भी हम $_SERVER[‘PHP_SELF’] द्वारा Access कर सकते हैं। ये Variable तब बहुत उपयोगी होता है, जब हम Self Referencing Scripts Create कर रहे होते हैं।

PHP in Hindiये Article इस वेबसाईट पर Selling हेतु उपलब्‍ध EBook PHP in Hindi से लिया गया है। इसलिए यदि ये Article आपके लिए उपयोगी रहा, तो निश्चित रूप से ये पुस्तक भी आपके लिए काफी उपयोगी साबित होगी। 

PHP in Hindi | Page: 647 | Format: PDF

BUY NOW GET DEMO REVIEWS