note 118247 added to function.array-key-exists

From: Date: Tue, 03 Nov 2015 05:42:28 +0000
Subject: note 118247 added to function.array-key-exists
Groups: php.notes 
Request: Send a blank email to php-notes+get-204073@lists.php.net to get a copy of this message
array_key_exists perfect for $_GET . As there will be browser level restriction on length of URL , number of keys in $_GET global variable will be very limited . So array_key_exists will not cause any performance overhead in this context . isset function can be conveniently ignored while handling $_GET variable. But for $_POST , the max array size has to be configure in server PHP configuration . So cannot rely on array_key_exists for $_POST if max array size is not optimized . Here is an example with array_key_exists switching between content-types : if(array_key_exists('format',$_GET)) { if($_GET['format']=="json") { header('Content-Type: application/json'); } else{ //handle any other format whitelisted for the application } } else { error_log("format parameter missing . using default html format"); header('Content-Type: text/html'); } ---- Server IP: 72.52.91.14 Probable Submitter: 103.19.212.21 (proxied: 103.19.212.253) ---- Manual Page -- http://php.net/manual/en/function.array-key-exists.php Edit -- https://master.php.net/note/edit/118247 Del: integrated -- https://master.php.net/note/delete/118247/integrated Del: useless -- https://master.php.net/note/delete/118247/useless Del: bad code -- https://master.php.net/note/delete/118247/bad+code Del: spam -- https://master.php.net/note/delete/118247/spam Del: non-english -- https://master.php.net/note/delete/118247/non-english Del: in docs -- https://master.php.net/note/delete/118247/in+docs Del: other reasons-- https://master.php.net/note/delete/118247 Reject -- https://master.php.net/note/reject/118247 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#204073) next »